Web platform support and limitations
developCachedNetworkImage and CachedNetworkImageProvider have minimal support for the web. Note that caching functionality is currently not included when running on the web platform.repository·develop·Indexed 25 days ago
https://github.com/baseflow/flutter_cached_network_imageA Flutter library for displaying network images with automatic local caching to improve performance and reduce data usage. It provides the CachedNetworkImage widget for high-level usage with placeholders, progress indicators, and error widgets, as well as CachedNetworkImageProvider for use in standard Image widgets. The library utilizes flutter_cache_manager for storage and offers features like memory/disk cache resizing, custom HTTP headers, and manual cache eviction.
CachedNetworkImage and CachedNetworkImageProvider have minimal support for the web. Note that caching functionality is currently not included when running on the web platform.flutter_cache_manager package.To customize the launch screen for the iOS version of your Flutter app, you can replace the image files located in the LaunchImage.imageset directory with your own assets.
Alternatively, you can manage these assets using Xcode:
open ios/Runner.xcworkspace.Runner/Assets.xcassets.open ios/Runner.xcworkspaceTo show the actual download progress of an image, use the progressIndicatorBuilder. This provides a downloadProgress object containing the current progress value.
```dart
CachedNetworkImage(
imageUrl: "http://via.placeholder.com/350x150",
progressIndicatorBuilder: (context, url, downloadProgress) =>
CircularProgressIndicator(value: downloadProgress.progress),
errorWidget: (context, url, error) => Icon(Icons.error),
),If you need to use the cached image within a specific layout (like a BoxDecoration or a Container), use the imageBuilder callback. This provides the imageProvider which you can then pass to other widgets or decorations.
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),
),The CachedNetworkImage widget is the primary way to display images from the internet while caching them locally. You can provide a placeholder widget to show while the image is loading and an errorWidget to display if the loading fails.
```dart
CachedNetworkImage(
imageUrl: "http://via.placeholder.com/350x150",
placeholder: (context, url) => CircularProgressIndicator(),
errorWidget: (context, url, error) => Icon(Icons.error),
),If you want to use the caching logic within a standard Flutter Image widget, use CachedNetworkImageProvider instead of the CachedNetworkImage widget.
Image(image: CachedNetworkImageProvider(url))You can customize how images are fetched and stored:
cacheManager: Pass a custom BaseCacheManager to control caching logic.httpHeaders: A Map<String, String> of headers to include in the HTTP request for the image.cacheKey: An optional key used to identify the image in the cache. If not provided, the imageUrl is used.useOldImageOnUrlChange: If set to true, the widget will animate from the old image to the new image when the imageUrl changes.errorListener to the CachedNetworkImageProvider constructor. This listener is triggered whenever the image loading process encounters an error, allowing you to implement custom error handling or logging logic.You can customize the UI during different stages of the image loading lifecycle using builder functions:
placeholder: A PlaceholderWidgetBuilder called while the image is loading. Receives BuildContext and the url.progressIndicatorBuilder: A ProgressIndicatorBuilder called during download. Receives BuildContext, url, and a DownloadProgress object containing expectedTotalBytes and cumulativeBytesLoaded.errorWidget: A LoadingErrorWidgetBuilder called if loading fails. Receives BuildContext, url, and the error object.imageBuilder: An ImageWidgetBuilder called after the image successfully loads. Receives BuildContext and the ImageProvider.To prevent high memory consumption or excessive disk usage, use the following properties:
memCacheWidth / memCacheHeight: Resizes the image in memory. This is highly recommended for large images displayed in small containers.maxWidthDiskCache / maxHeightDiskCache: Resizes the image before storing it in the disk cache.CachedNetworkImageProvider is a public ImageProvider that allows you to load network images using a cache. It can be used in any Flutter widget that accepts an ImageProvider (such as DecorationImage or CircleAvatar), providing an alternative to the standard CachedNetworkImage widget when you need more low-level control.