Skip to content

Instantly share code, notes, and snippets.

@agarasul
Created July 31, 2019 14:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save agarasul/2767c6eb6e2c3c443096e013183e61b8 to your computer and use it in GitHub Desktop.
Save agarasul/2767c6eb6e2c3c443096e013183e61b8 to your computer and use it in GitHub Desktop.
void getData() async {
var response = await http.get(
"https://newsapi.org/v2/top-headlines?country=us&apiKey=821a22ad51e240fb9c131c4b00009630");
setState(() {
if (response.statusCode == 200) {
items.addAll(News.fromJson(json.decode(response.body)).articles);
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment