0

This is my response from POSTMAN enter image description here

I want to display thumbnail url image into Flutter Gridview Builder.

Future<List<Photo>> fetchPhotos(http.Client client) async {
  var headers = {
    'Authorization': 'Bearer $bearer_token'
  };
  var request = http.Request('GET', Uri.parse('https://xxxxx.execute-api.us-east-2.amazonaws.com/stg/assets'));

  request.headers.addAll(headers);

  http.StreamedResponse response = await request.send();

  if (response.statusCode == 200) {
   // print(await response.stream.bytesToString());
    return compute(parsePhotos, response.body);
  }
  else {
    print(response.reasonPhrase);
  }
}
user2349088
  • 11
  • 1
  • 3
  • add your code snippet – Ravindra S. Patil Aug 10 '21 at 05:49
  • Future> fetchPhotos(http.Client client) async { var headers = { 'Authorization': 'Bearer $bearer_token' }; var request = http.Request('GET', Uri.parse('https://xxxxx.execute-api.us-east-2.amazonaws.com/stg/assets')); request.headers.addAll(headers); http.StreamedResponse response = await request.send(); if (response.statusCode == 200) { // print(await response.stream.bytesToString()); return compute(parsePhotos, response.body); } else { print(response.reasonPhrase); } } – user2349088 Aug 10 '21 at 06:06
  • If you get Data from API refer my answer [here](https://stackoverflow.com/a/68533647/13997210) or [here](https://stackoverflow.com/a/68594656/13997210) or [here](https://stackoverflow.com/a/68709502/13997210) hope its help to you – Ravindra S. Patil Aug 10 '21 at 06:24

1 Answers1

0

i dont know it work for you but i did this which give me everything fine

       Future getSections(BuildContext context,String token,int id) async {
try {
  Uri uri = Uri.parse('${links.classesUrl}/$id${links.sectionListUrl}');
  Response response = await get(uri, headers: {
    HttpHeaders.contentTypeHeader: 'application/json',
    HttpHeaders.authorizationHeader: 'Bearer $token',
  });
  if (response.statusCode == 200) {
    return jsonDecode(response.body);
  } else {
    print(response.statusCode);
  }
} catch (e) {
  print(e);

}}

Adnan haider
  • 553
  • 8
  • 21