DisposableCachedImage.network constructor

DisposableCachedImage.network({
  1. bool keepAlive = false,
  2. required String imageUrl,
  3. Map<String, String>? headers,
  4. int? maxCacheWidth,
  5. int? maxCacheHeight,
  6. BoxFit? fit,
  7. Rect? centerSlice,
  8. double scale = 1.0,
  9. bool addRepaintBoundaries = true,
  10. OnImage? onImage,
  11. BoxShape shape = BoxShape.rectangle,
  12. Color? color,
  13. AlignmentGeometry alignment = Alignment.center,
  14. OnLoading? onLoading,
  15. bool isAntiAlias = false,
  16. bool invertColors = false,
  17. double? height,
  18. BlendMode? colorBlendMode,
  19. bool resizeImage = false,
  20. bool isDynamicHeight = false,
  21. bool matchTextDirection = false,
  22. BorderRadius? borderRadius,
  23. double? width,
  24. ImageRepeat repeat = ImageRepeat.noRepeat,
  25. FilterQuality filterQuality = FilterQuality.none,
  26. OnError? onError,
  27. Duration fadeDuration = const Duration(milliseconds: 300),
  28. Key? key,
  29. bool keepBytesInMemory = true,
  30. Widget progressBuilder(
    1. BuildContext context,
    2. double progress
    )?,
})

Create a widget that displays image from the network and cache it in cache directory.

Either the width and height arguments should be specified, or the widget should be placed in a context that sets tight layout constraints. Otherwise, the image dimensions will change as the image is loaded, which will result in ugly layout changes.

Implementation

DisposableCachedImage.network({
  this.keepAlive = false,
  required final String imageUrl,
  final Map<String, String>? headers,
  this.maxCacheWidth,
  this.maxCacheHeight,
  this.fit,
  this.centerSlice,
  this.scale = 1.0,
  this.addRepaintBoundaries = true,
  this.onImage,
  this.shape = BoxShape.rectangle,
  this.color,
  this.alignment = Alignment.center,
  this.onLoading,
  this.isAntiAlias = false,
  this.invertColors = false,
  this.height,
  this.colorBlendMode,
  this.resizeImage = false,
  this.isDynamicHeight = false,
  this.matchTextDirection = false,
  this.borderRadius,
  this.width,
  this.repeat = ImageRepeat.noRepeat,
  this.filterQuality = FilterQuality.none,
  this.onError,
  this.fadeDuration = const Duration(milliseconds: 300),
  final Key? key,
  this.keepBytesInMemory = true,
  this.progressBuilder,
})  : assert(
        !isDynamicHeight || width != null,
        'Image width must be specified for dynamic size',
      ),
      assert(
        !resizeImage || width != null || height != null,
        'Either height or width must be specified when resizeImage is enabled',
      ),
      _arguments = _ImageProviderArguments(
        image: imageUrl,
        maxCacheWidth: maxCacheWidth,
        maxCacheHeight: maxCacheHeight,
        keepAlive: keepAlive,
        headers: headers,
        resizeImage: resizeImage,
        keepBytesInMemory: keepBytesInMemory,
        widgetHeight: height?.toInt(),
        widgetWidth: width?.toInt(),
      ),
      _provider = _networkImageProvider,
      super(key: key);