Skip to content
pubscout

network_to_file_image

7.0.1, released 3 days ago by glasberg.dev

Combines NetworkImage and FileImage to cache network images onto the local file system.

$ flutter pub add network_to_file_image
Source repository

What it does

It attempts to load an image from a local file. If the file does not exist, it fetches the image from a network URL, saves it to the local file for future use, and displays it.

AI-written summary of version 7.0.0, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You need to persistently cache network images to disk for offline use.
  • You want to manage exact local file paths for downloaded network images.

Skip it when

  • You require complex cache eviction policies like max size or automatic expiration based on headers.
  • You do not have a local directory path readily available via path_provider.

Strengths

  • Simple combination of NetworkImage and FileImage.
  • Works with Canvas and custom painters via ImageForCanvas.
  • Built-in mocking support for tests.

Weaknesses

  • Ignores server cache headers completely.
  • Requires manual management of local file directories.

Setup

Kind
Flutter widgets
Effort
Low
Code generation
No
Direct dependencies
0

Requires the path_provider package to supply local directory paths for saving files.

Image(
  image: NetworkToFileImage(
    url: "https://example.com/someFile.png", 
    file: myFile,
  ),
)

Alternatives

Packages that do the same job and could replace network_to_file_image.

  • cached_network_image

    Provides a more full-featured image caching solution with placeholders, error widgets, and automatic cache management out of the box.