cached_network_image 2.0.0-rc.1 copy "cached_network_image: ^2.0.0-rc.1" to clipboard
cached_network_image: ^2.0.0-rc.1 copied to clipboard

outdated

Flutter library to load and cache network images. Can also be used with placeholder and error widgets.

Breaking change with ImageProvider.load in Flutter 1.10

The Flutter team made a breaking change with the ImageProvider in Flutter 1.10.15 (currently Master channel only).

If you are experiencing one of the following errors upgrade to 2.0.0-rc.

The method 'ScaledFileImage.load' has fewer positional arguments than those of overridden method 'ImageProvider.load'
The method 'CachedNetworkImageProvider.load' has fewer positional arguments than those of overridden method 'ImageProvider.load'

Cached network image #

Widget now uses builders for the placeholder and error widget and uses sqflite for cache management. See the docs for more information.

pub package Donate

A flutter library to show images from the internet and keep them in the cache directory.

How to use #

The CachedNetworkImage can be used directly or through the ImageProvider.

CachedNetworkImage(
        imageUrl: "http://via.placeholder.com/350x150",
        placeholder: (context, url) => CircularProgressIndicator(),
        errorWidget: (context, url, error) => Icon(Icons.error),
     ),
Image(image: CachedNetworkImageProvider(url))

When you want to have both the placeholder functionality and want to get the imageprovider to use in another widget you can provide an imageBuilder:

CachedNetworkImage(
  imageUrl: "http://via.placeholder.com/200x150",
  imageBuilder: (context, imageProvider) => Container(
    decoration: BoxDecoration(
      image: DecorationImage(
          image: imageProvider,
          fit: BoxFit.cover,
          colorFilter:
              ColorFilter.mode(Colors.red, BlendMode.colorBurn)),
    ),
  ),
  placeholder: (context, url) => CircularProgressIndicator(),
  errorWidget: (context, url, error) => Icon(Icons.error),
),

How it works #

The cached network images stores and retrieves files using the flutter_cache_manager.

6390
likes
0
pub points
100%
popularity

Publisher

verified publisherbaseflow.com

Flutter library to load and cache network images. Can also be used with placeholder and error widgets.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, flutter_cache_manager

More

Packages that depend on cached_network_image