Back

[SOLVED] Caching an image in FutureBuilder

  • 0
  • Flutter
  • Storage
mmjsmohit
7 Jun, 2023, 03:35

Hi! I am trying to cache an image I am pulling from Appwrite Storage using cached_network_image package in Flutter. The CachedNetworkImage lives inside a FutureBuilder and it's firing everytime. I've also attached the code. I've also tried to use the AsyncMemorizer in the dart:async package but no progress. Any fixes?

TL;DR
The user is trying to cache an image in Flutter using the `cached_network_image` package. They are using a `FutureBuilder` but it is firing every time. They have tried using `AsyncMemorizer` from the `dart:async` package but it hasn't worked. The user is looking for a solution to cache the image and download the future only once.
mmjsmohit
7 Jun, 2023, 03:38

Thanks. WIll have a look an revert back in a while!

mmjsmohit
7 Jun, 2023, 04:20

@Steven I am afraid it is not a correct solution.

mmjsmohit
7 Jun, 2023, 04:21

I used getFileView and it is still making requests.

Drake
7 Jun, 2023, 04:21

The suggestion in the discussion did not say to call that function

mmjsmohit
7 Jun, 2023, 04:28

Then?

mmjsmohit
7 Jun, 2023, 04:28

I can see the discussion says you need to call getFileView instead of getFileDownload

mmjsmohit
7 Jun, 2023, 04:30

To clarify, I need to cache the image and download the Future only once. In this case, the FutureBuilder is firing everytime.

Drake
7 Jun, 2023, 04:33

It says to use the url and pass it into network image widget

mmjsmohit
7 Jun, 2023, 05:09

Solved. The solution was to just remove FutureBuilder and follow the rest of discussion you provided. Thanks for the help @Steven !

mmjsmohit
7 Jun, 2023, 05:09

[SOLVED] Caching an image in FutureBuilder

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more