flutter_cache_manager icon indicating copy to clipboard operation
flutter_cache_manager copied to clipboard

Use a custom key for caching

Open forresthuhu opened this issue 4 months ago • 1 comments

How can I use a custom key for caching instead of the url? When I use the CachedNetworkImage widget, I want to use the customized cache manager. My thought was to extend CacheManager and override its getSingleFile and other methods. But it doesn't seem to work.

forresthuhu avatar Sep 03 '25 08:09 forresthuhu

I haven't used CachedNetworkImage, but I have used the putFile function, which has a key parameter. You can then get the file using CacheManager.getFileFromCache. So, you can first check if the file exists using this function, and if it doesn't, then you can download it (using http, dio, or something else) and use the putFile function to store it.

HeftyCoder avatar Oct 23 '25 22:10 HeftyCoder