1

I'm using a POST request (with a json body) to retrieve a png image (a qr code). How could I display such image? I checked with image.network but it seems it only handles GET request.

woshitom
  • 4,811
  • 8
  • 38
  • 62

2 Answers2

2

If your response body are png image bytes, then you can try using Image.memory constructor as follows

Image img = Image.memory(response.bodyBytes).image;

You should check out Image.memory and also MemoryImage

bluenile
  • 5,673
  • 3
  • 16
  • 29
0

You could use a FutureBuilder for that - the http.post returns a Future<Response> which you need to decode to get to your image url from the response body. (Pass the http.post call to a decoding function returning a Future<String> which is your final image url).

As soon as the Future is resolved you can then build the Image using Image.network

Also have a look at this: How do I update a placeholder image with an async image? as it seems to be related.

Damian K. Bast
  • 1,074
  • 7
  • 18