Skip to content

Instantly share code, notes, and snippets.

@theindianappguy
Created May 18, 2020 12:56
Show Gist options
  • Save theindianappguy/0c40cacebadc40b9472bef0e08755583 to your computer and use it in GitHub Desktop.
Save theindianappguy/0c40cacebadc40b9472bef0e08755583 to your computer and use it in GitHub Desktop.
getTrendingWallpaper() async {
await http.get(
"https://api.pexels.com/v1/curated?per_page=$noOfImageToLoad&page=1",
headers: {"Authorization": apiKEY}).then((value) {
//print(value.body);
Map<String, dynamic> jsonData = jsonDecode(value.body);
jsonData["photos"].forEach((element) {
//print(element);
PhotosModel photosModel = new PhotosModel();
photosModel = PhotosModel.fromMap(element);
photos.add(photosModel);
//print(photosModel.toString()+ " "+ photosModel.src.portrait);
});
setState(() {});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment