cached_network_image
(or better said flutter_cache_manager
) stores the images for long time - no need for shared preferences.
But it only does so, when instructed by the cache headers. So you have to make sure your server is returning the correct Cache-Control
headers.
If this is not possible, you can create your own FileService
and for the FileServiceResponse
pass a validTill
which is far in the future.
You can check the source code of the package for the default FileService
implementation which looks at the Cache-Control
headers:
https://github.com/Baseflow/flutter_cache_manager/blob/3bd49b866d9b5e6ce09d2283f0ef97488be97e1d/flutter_cache_manager/lib/src/web/file_service.dart#L85-L106