Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save theindianappguy/7a5d499b45199eea6b20240e11aacf7b to your computer and use it in GitHub Desktop.

Select an option

Save theindianappguy/7a5d499b45199eea6b20240e11aacf7b to your computer and use it in GitHub Desktop.
getSearchWallpaper(String searchQuery) async {
await http.get(
"https://api.pexels.com/v1/search?query=$searchQuery&per_page=30&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