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.

2 Answers 2

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

Sign up to request clarification or add additional context in comments.

Comments

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.