cached_network_image 2.0.0-rc

  • Readme
  • Changelog
  • Example
  • Installing
  • 63

Cached network image #

BREAKING CHANGES IN 0.6.0

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.

[2.0.0-rc] - 2019-10-17

[1.1.2+1] - 2019-10-17

  • Fix for widgets declared with infinite size.

[1.1.2] - 2019-10-16

  • Add filterQuality property.
  • Scale image to size when showing in widget.
  • Better error handling.
  • Fix for useOldImageOnUrlChange.
  • Update cache manager to 1.1.2.

[1.1.1] - 2019-07-23

  • Updated cache manager for error handling fix

[1.1.0] - 2019-07-13

  • Improved performance
  • Keep fetched files in sync with filemanager.
  • Better error handling.
  • Added extra example to show the imageBuilder

[1.0.0] - 2019-06-27

  • Updated dependencies

[0.8.0] - 2019-05-06

  • Fixed compile error on informationCollector by temporarily disabling it.

[0.7.0] - 2019-03-06

  • BREAKING CHANGE: Renamed ErrorWidgetBuilder to LoadingErrorWidgetBuilder
  • LoadingErrorWidgetBuilder returns an Object instead of an Exception
  • Fixed BoxFit to also work when size is not defined

[0.6.2] - 2019-02-27

  • Added option to blend image with color
  • Added option in CacheManager to clear the cache

[0.6.1] - 2019-02-25 BREAKING CHANGES

  • No longer assume infinite size.

[0.6.0] - 2019-02-18 BREAKING CHANGES

  • Breaking changes in API and behaviour
  • Very much improved though
  • Adapted for new cache manager library
  • Completely rewritten image view
  • Now using builders for placeholder and error widgets
  • Added optional builder to customize the image

[0.5.1] - 2018-11-19

  • Fixed error throwing

[0.5.0] - 2018-10-13

  • Updated cache manager for http 0.12.0

[0.4.2] - 2018-08-30

  • Updated cache manager dependency

[0.4.1] - 2018-04-27

  • Improved error handling when a file could not be loaded.

[0.4.0] - 2018-04-14

  • Added optional headers.
  • Changed to Dart 2.0
  • Fixed bug when updating widget with new url

[0.3.0] - 2018-02-09

  • Added CachedNetworkImage with placeholder and error widgets.

[0.2.1] - 2018-01-08

  • Moved from OneFrameImageStreamCompleter to MultiFrameImageStreamCompleter.
  • Updated CacheManager dependency for critical bug fix.

[0.2.0] - 2017-12-29

  • Breaking change Removed CachedNetworkImage. From now on only the ImageProvider is supported. For a placeholder use FadeInImage. See also "Fallback for Network Images".
  • Moved CacheManager to a separate library for a more generic purpose.

[0.1.0] - 2017-12-21

  • Breaking change. Upgraded to Gradle 4.1 and Android Studio Gradle plugin 3.0.1. Older Flutter projects need to upgrade their Gradle setup as well in order to use this version. Instructions can be found here.

[0.0.2] - 10 December 2017

Added an ImageProvider and improved documentation

[0.0.1] - 2 December 2017

Initial release, should be polished

example/README.md

example #

A new Flutter project.

Getting Started #

For help getting started with Flutter, view our online documentation.

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  cached_network_image: ^2.0.0-rc

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:cached_network_image/cached_network_image.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
100
Health:
Code health derived from static analysis. [more]
0
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
65
Overall:
Weighted score of the above. [more]
63
Learn more about scoring.

We analyzed this package on Nov 21, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.6.1
  • pana: 0.12.21
  • Flutter: 1.9.1+hotfix.6

Analysis issues and suggestions

Fix dependencies in pubspec.yaml.

Running flutter pub upgrade failed with the following output:

ERR: The current Flutter SDK version is 1.9.1+hotfix.6.
 
 Because cached_network_image requires Flutter SDK version >=1.10.15-pre.148 <2.0.0, version solving failed.

Maintenance issues and suggestions

Fix platform conflicts. (-20 points)

Error(s) prevent platform classification:

Fix dependencies in pubspec.yaml.

Make sure dartdoc successfully runs on your package's source files. (-10 points)

Dependencies were not resolved.

Package is pre-release. (-5 points)

Pre-release versions should be used with caution; their API can change in breaking ways.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.28.0 <3.0.0