cached_network_image 0.5.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 59

Cached network image #

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.

new CachedNetworkImage(
       imageUrl: "",
       placeholder: new CircularProgressIndicator(),
       errorWidget: new Icon(Icons.error),
new Image(image: new CachedNetworkImageProvider(url))

How it works #

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

[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


import 'package:flutter/material.dart';
import 'package:cached_network_image/cached_network_image.dart';

void main() => runApp(new MyApp());

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  Widget build(BuildContext context) {
    return new MaterialApp(
      title: 'CachedNetworkImage Demo',
      theme: new ThemeData(
        // This is the theme of your application.
        // Try running your application with "flutter run". You'll see the
        // application has a blue toolbar. Then, without quitting the app, try
        // changing the primarySwatch below to and then invoke
        // "hot reload" (press "r" in the console where you ran "flutter run",
        // or press Run > Flutter Hot Reload in IntelliJ). Notice that the
        // counter didn't reset back to zero; the application is not restarted.
      home: new MyHomePage(title: 'CachedNetworkImage'),

class MyHomePage extends StatelessWidget {
  final String title;

  Widget build(BuildContext context) {
    return new Scaffold(
      appBar: new AppBar(
        // Here we take the value from the MyHomePage object that was created by
        // the method, and use it to set our appbar title.
        title: new Text(title),
      new SingleChildScrollView(child:
      new Center(
        child: new Column(
          children: <Widget>[

              new Image(
                image: new CachedNetworkImageProvider(""),

              new CachedNetworkImage(
                imageUrl: "",

              new CachedNetworkImage(
                imageUrl: "not a valid uri",
                placeholder: new CircularProgressIndicator(),
                errorWidget: new Icon(Icons.error),

              new CachedNetworkImage(
                imageUrl: "",
                placeholder: new CircularProgressIndicator(),
                errorWidget: new Icon(Icons.error),
                fadeOutDuration: new Duration(seconds: 1),
                fadeInDuration: new Duration(seconds: 3),


  Widget _sizedContainer(Widget child) {
    return new SizedBox(
      width: 300.0,
      height: 150.0,
      child: new Center(
        child: child,

Use this package as a library

1. Depend on it

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

  cached_network_image: ^0.5.0

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';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on May 16, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.1
  • pana: 0.13.8-dev
  • Flutter: 1.17.0

Health issues and suggestions

Fix lib/cached_network_image.dart. (-76.51 points)

Analysis of lib/cached_network_image.dart failed with 5 errors, 2 hints, including:

line 199 col 38: The argument type 'void Function(ImageInfo, bool)' can't be assigned to the parameter type 'ImageStreamListener'.

line 200 col 32: The argument type 'void Function(ImageInfo, bool)' can't be assigned to the parameter type 'ImageStreamListener'.

line 210 col 34: The argument type 'void Function(ImageInfo, bool)' can't be assigned to the parameter type 'ImageStreamListener'.

line 460 col 24: 'CachedNetworkImageProvider.load' ('ImageStreamCompleter Function(CachedNetworkImageProvider)') isn't a valid override of 'ImageProvider.load' ('ImageStreamCompleter Function(CachedNetworkImageProvider, Future

line 464 col 9: The argument type 'Null Function(StringBuffer)' can't be assigned to the parameter type 'Iterable

Maintenance issues and suggestions

No valid SDK. (-20 points)

The analysis could not detect a valid SDK that can use this package.

Support latest dependencies. (-10 points)

The version constraint in pubspec.yaml does not support the latest published versions for 1 dependency (flutter_cache_manager).

Package is getting outdated. (-59.18 points)

The package was last published 83 weeks ago.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.28.0 <3.0.0
flutter 0.0.0
flutter_cache_manager ^0.2.0 0.2.0+1 1.2.2
Transitive dependencies
charcode 1.1.3
collection 1.14.12
convert 2.1.1
crypto 2.1.4
http 0.12.1
http_parser 3.1.4
meta 1.1.8
path 1.7.0
path_provider 0.4.1 1.6.8
pedantic 1.9.0
shared_preferences 0.4.3 0.5.7+2
sky_engine 0.0.99
source_span 1.7.0
string_scanner 1.0.5
synchronized 1.5.3+2 2.2.0
term_glyph 1.1.0
typed_data 1.1.6
uuid 1.0.3 2.0.4
vector_math 2.0.8
Dev dependencies
test ^1.3.0