cached_network_image_ce 4.0.0
cached_network_image_ce: ^4.0.0 copied to clipboard
Community Edition Flutter library to load and cache network images. Can also be used with placeholder and error widgets.
Cached Network Image — Community Edition #
A Flutter library to show images from the internet and keep them in the cache directory. Community maintained fork of cached_network_image.
Why this fork? #
The original cached_network_image by Baseflow has been unmaintained for over 2 years, with no updates, bug fixes, or responses to issues and pull requests. This community edition was created to:
- Keep the package alive — continue fixing bugs and adding features the community needs.
- Replace
sqflitewithhive_cefor cache storage — the original package depended onflutter_cache_manager(also by Baseflow) which usedsqfliteunder the hood. This community edition useshive_ceinstead, which is more performant and actively maintained. - Stay up-to-date with the latest Flutter and Dart SDK versions.
How to use #
The CachedNetworkImage can be used directly or through the ImageProvider.
Both CachedNetworkImage and CachedNetworkImageProvider have minimal support for web (currently without caching).
With a placeholder:
CachedNetworkImage(
imageUrl: 'https://via.placeholder.com/350x150',
placeholder: (context, url) => CircularProgressIndicator(),
errorWidget: (context, url, error) => Icon(Icons.error),
),
Or with a progress indicator:
CachedNetworkImage(
imageUrl: 'https://via.placeholder.com/350x150',
progressIndicatorBuilder: (context, url, downloadProgress) =>
CircularProgressIndicator(value: downloadProgress.progress),
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 image provider to use in another widget you can provide an imageBuilder:
CachedNetworkImage(
imageUrl: 'https://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.
FAQ #
My app crashes when the image loading failed. (I know, this is not really a question.) #
Does it really crash though? The debugger might pause, as the Dart VM doesn't recognize it as a caught exception; the console might print errors; even your crash reporting tool might report it (I know, that really sucks). However, does it really crash? Probably everything is just running fine. If you really get an app crash you are fine to report an issue, but do that with a small example so we can reproduce that crash.
Contributing #
Contributions are welcome! Please see the contributing guide for details.
License #
This project is licensed under the MIT License.