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.
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: "http://via.placeholder.com/350x150", placeholder: (context, url) => new CircularProgressIndicator(), errorWidget: (context, url, error) => 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.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
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: ^0.6.0+1
2. Install it
You can install packages from the command line:
$ flutter pub get
Alternatively, your editor might support
flutter pub get.
Check the docs for your editor to learn more.
3. Import it
Now in your Dart code, you can use:
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]
We analyzed this package on Jan 29, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:
- Dart: 2.7.1
- pana: 0.13.4
- Flutter: 1.12.13+hotfix.5
Health issues and suggestions
lib/src/old_widget.dart. (-57.81 points)
lib/src/old_widget.dart failed with 3 errors:
line 189 col 38: The argument type 'void Function(ImageInfo, bool)' can't be assigned to the parameter type 'ImageStreamListener'.
line 190 col 32: The argument type 'void Function(ImageInfo, bool)' can't be assigned to the parameter type 'ImageStreamListener'.
line 200 col 34: The argument type 'void Function(ImageInfo, bool)' can't be assigned to the parameter type 'ImageStreamListener'.
lib/src/cached_network_image_provider.dart. (-44.03 points)
lib/src/cached_network_image_provider.dart failed with 2 errors, 1 hint:
line 42 col 24: 'CachedNetworkImageProvider.load' ('ImageStreamCompleter Function(CachedNetworkImageProvider)') isn't a valid override of 'ImageProvider.load' ('ImageStreamCompleter Function(CachedNetworkImageProvider, Future
line 46 col 9: The argument type 'Null Function(StringBuffer)' can't be assigned to the parameter type 'Iterable
line 46 col 31: This function has a return type of 'Iterable
Maintenance issues and suggestions
Support latest dependencies. (-10 points)
The version constraint in
pubspec.yaml does not support the latest published versions for 1 dependency (
|Dart SDK||>=2.0.0-dev.28.0 <3.0.0|