Jiehfeng
Jiehfeng

Reputation: 1027

Best way to store images from bytes and get from cache?

I am making requests to my API to fetch images, it returns the bytes for the image. So what I do is I assign response.bodyBytes to a Uint8List.

Then I can display the image in a Image.memory() widget.

How do I store large amounts of images in the phone memory, and check if it exists in memory before making more requests to my API?

Upvotes: 0

Views: 803

Answers (1)

Jiehfeng
Jiehfeng

Reputation: 1027

I figured it out. I was using a Flask for my API and I used send_file() to send it as a rendered image instead, now I can use the standard cached_network_image as a URL. I just had to change it from POST to GET, and use params instead of headers so I could use the imageURL property.

Upvotes: 1

Related Questions