Package selection guidance compiled from public package information, community data, and project usage.
A Flutter package that efficiently manages image loading by first checking for a local file. If the image is not found locally, it downloads it from the network and saves it to disk for future use, reducing redundant downloads and improving performance. Ideal for apps requiring persistent image caching with minimal setup.
Use cases
Caching remote images for offline access
Reducing repeated network requests
Improving app performance with local storage
Displaying user profile pictures with fallbacks
Loading images in list views with persistence
Key features
Local file check before network fetch
Automatic image saving after download
Built-in caching mechanism
Supports multiple platforms
Simple API integration
Suitable for
Apps needing offline image availability
Image-heavy applications
Developers seeking lightweight caching
Projects with limited backend infrastructure
Apps targeting mobile and desktop platforms
Considerations
Requires file system permissions on some platforms
Disk space usage increases over time
No built-in expiration or cleanup strategy
May need manual cache management
Limited control over cache size or TTL
Original README
Original README snapshot from the linked source repository. Visit the repository for the latest content.
network_to_file_image
This package combines NetworkImage and FileImage to:
Download the image once from the URL,
Save it to the local file system,
Use the saved image from the file system from then on.
In more detail:
Given a file and url of an image, it first tries to read it from the local file. It decodes the
given File object as an image, associating it with the given scale.
However, if the image doesn't yet exist as a local file, it fetches the given URL from the network,
associating it with the given scale, and then saves it to the local file. The image will be cached
regardless of cache headers from the server.
Notes:
If the provided url is null or empty, NetworkToFileImage will default to FileImage. It will
read the image from the local file, and won't try to download it from the network.
If the provided file is null, NetworkToFileImage will default to NetworkImage. It will
download the image from the network, and won't save it locally.
You can set mock files (local and in the network). Please see methods:
setMockFile(File file, Uint8List bytes)
setMockUrl(String url, Uint8List bytes)
clearMocks()
clearMockFiles()
clearMockUrls()
Your mocked urls are usually only seen by the NetworkToFileImage class. However, you may override
the default Dart http methods so that these urls are visible to other ImageProviders.