Reputation: 1379
I'm using the package flutter_cached_network_image to load images from firebase. When a user updates his profile picture (filename is still the same) the image that is loaded is still the same as the one before the update because it is loaded from cache (because it still has the same url as before). Is it possible to clear the picture from the cache so the new image is loaded?
Upvotes: 2
Views: 4344
Reputation: 38
I had the same issue. This helped me this:
imageCache.clearLiveImages();
imageCache.clear();
_bloc.add(ReloadEvent());
Cleaning cache and rebuilding widgets after successfully updating photo.
Upvotes: 2
Reputation: 1584
Like @EderBaum said, you can force puting an additional query string input, the value depends of the effect that you want, for example:
1 - Never cache http:urlofresource.com/yourimage.jpg?version={NewRandonNumberGenerated}
You can use Random
class to achieve this.
2- Reload cache based on app version
Same that before, but now, you use an version information that you can put into your global state or somewhere else to retrieve information after an update
3 - Use normal cache
Just leave the widget do the job.
Upvotes: 1
Reputation: 1141
Apparently there is no solution at the moment. See here: https://github.com/Baseflow/flutter_cached_network_image/issues/77
I use the version of the image in the address to get around this. Something like: https://example.com/image.jpg?version=14
Upvotes: 4