Just want to get clarification on below coding. cacheDuration set seconds to 0 caches avatar.jpg for the app session, any subsequent used is getting from cache. Once app is closed, avatar.jpg will be deallocated from cache. Am I right ?
CachedNetworkImage(
imageUrl: ‘https://example.com/avatar.jpg’,
cacheDuration: const Duration(seconds: 0),
);
2
Answers
The image is stored in memory during your session, rather than on your device’s disk. It will be removed from the cache once you close the app.
cached_network_image use the flutter_cache_manager library to manage cached files. Here is what the doc says :
So I think your solution with a Duration of 0 will work but you can also try a cleaner solution (I think): try to delete all the cached image at the start of your app (in the
main()
method for exemple).To clean all cache you can try this (it will remove old cached images):