CachedNetworkImage constructor

CachedNetworkImage({
  1. Key? key,
  2. required String imageUrl,
  3. Map<String, String>? httpHeaders,
  4. ImageWidgetBuilder? imageBuilder,
  5. PlaceholderWidgetBuilder? placeholder,
  6. ProgressIndicatorBuilder? progressIndicatorBuilder,
  7. LoadingErrorWidgetBuilder? errorWidget,
  8. Duration? fadeOutDuration = const Duration(milliseconds: 1000),
  9. Curve fadeOutCurve = Curves.easeOut,
  10. Duration fadeInDuration = const Duration(milliseconds: 500),
  11. Curve fadeInCurve = Curves.easeIn,
  12. double? width,
  13. double? height,
  14. BoxFit? fit,
  15. Alignment alignment = Alignment.center,
  16. ImageRepeat repeat = ImageRepeat.noRepeat,
  17. bool matchTextDirection = false,
  18. BaseCacheManager? cacheManager,
  19. bool useOldImageOnUrlChange = false,
  20. Color? color,
  21. FilterQuality filterQuality = FilterQuality.low,
  22. BlendMode? colorBlendMode,
  23. Duration? placeholderFadeInDuration,
  24. int? memCacheWidth,
  25. int? memCacheHeight,
  26. String? cacheKey,
  27. int? maxWidthDiskCache,
  28. int? maxHeightDiskCache,
  29. ValueChanged<Object>? errorListener,
  30. ImageRenderMethodForWeb imageRenderMethodForWeb = ImageRenderMethodForWeb.HtmlImage,
  31. double scale = 1.0,
})

CachedNetworkImage shows a network image using a caching mechanism. It also provides support for a placeholder, showing an error and fading into the loaded image. Next to that it supports most features of a default Image widget.

Implementation

CachedNetworkImage({
  super.key,
  required this.imageUrl,
  this.httpHeaders,
  this.imageBuilder,
  this.placeholder,
  this.progressIndicatorBuilder,
  this.errorWidget,
  this.fadeOutDuration = const Duration(milliseconds: 1000),
  this.fadeOutCurve = Curves.easeOut,
  this.fadeInDuration = const Duration(milliseconds: 500),
  this.fadeInCurve = Curves.easeIn,
  this.width,
  this.height,
  this.fit,
  this.alignment = Alignment.center,
  this.repeat = ImageRepeat.noRepeat,
  this.matchTextDirection = false,
  this.cacheManager,
  this.useOldImageOnUrlChange = false,
  this.color,
  this.filterQuality = FilterQuality.low,
  this.colorBlendMode,
  this.placeholderFadeInDuration,
  this.memCacheWidth,
  this.memCacheHeight,
  this.cacheKey,
  this.maxWidthDiskCache,
  this.maxHeightDiskCache,
  this.errorListener,
  ImageRenderMethodForWeb imageRenderMethodForWeb =
      ImageRenderMethodForWeb.HtmlImage,
  double scale = 1.0,
}) : _image = CachedNetworkImageProvider(
        imageUrl,
        headers: httpHeaders,
        cacheManager: cacheManager,
        cacheKey: cacheKey,
        imageRenderMethodForWeb: imageRenderMethodForWeb,
        maxWidth: maxWidthDiskCache,
        maxHeight: maxHeightDiskCache,
        errorListener: errorListener,
        scale: scale,
      );