OctoImage constructor

OctoImage({
  1. Key? key,
  2. required ImageProvider<Object> image,
  3. OctoImageBuilder? imageBuilder,
  4. OctoPlaceholderBuilder? placeholderBuilder,
  5. OctoProgressIndicatorBuilder? progressIndicatorBuilder,
  6. OctoErrorBuilder? errorBuilder,
  7. Duration? fadeOutDuration,
  8. Curve? fadeOutCurve,
  9. Duration? fadeInDuration,
  10. Curve? fadeInCurve,
  11. double? width,
  12. double? height,
  13. BoxFit? fit,
  14. Alignment? alignment,
  15. ImageRepeat? repeat,
  16. bool? matchTextDirection,
  17. Color? color,
  18. FilterQuality? filterQuality,
  19. BlendMode? colorBlendMode,
  20. Duration? placeholderFadeInDuration,
  21. bool? gaplessPlayback,
  22. int? memCacheWidth,
  23. int? memCacheHeight,
})

Creates an OctoWidget that displays an image. The image is an ImageProvider and the OctoImage should work with any ImageProvider. The widget is optimized for CachedNetworkImageProvider or NetworkImage, as for those it makes sense to show download progress or an error widget.

The placeholderBuilder or progressIndicatorBuilder can be set to show a placeholder widget. At most one of these two should be set. The progressIndicatorBuilder is called every time new progress information is available, so if you don't use that progress info in your widget you should use placeholderBuilder which is not called so often.

The imageBuilder can be used for image transformations after the image is loaded.

When the image failed loading the errorBuilder is called with the error and stacktrace. This can be used to show an error widget.

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.

Use filterQuality to change the quality when scaling an image. Use the FilterQuality.low quality setting to scale the image, which corresponds to bilinear interpolation, rather than the default FilterQuality.none which corresponds to nearest-neighbor.

If excludeFromSemantics is true, then semanticLabel will be ignored.

If memCacheWidth or memCacheHeight are provided, it indicates to the engine that the image must be decoded at the specified size. The image will be rendered to the constraints of the layout or width and height regardless of these parameters. These parameters are primarily intended to reduce the memory usage of ImageCache.

Implementation

OctoImage({
  Key? key,
  required ImageProvider image,
  this.imageBuilder,
  this.placeholderBuilder,
  this.progressIndicatorBuilder,
  this.errorBuilder,
  Duration? fadeOutDuration,
  Curve? fadeOutCurve,
  Duration? fadeInDuration,
  Curve? fadeInCurve,
  this.width,
  this.height,
  this.fit,
  Alignment? alignment,
  ImageRepeat? repeat,
  bool? matchTextDirection,
  this.color,
  FilterQuality? filterQuality,
  this.colorBlendMode,
  Duration? placeholderFadeInDuration,
  bool? gaplessPlayback,
  int? memCacheWidth,
  int? memCacheHeight,
})  : image = ResizeImage.resizeIfNeeded(
        memCacheWidth,
        memCacheHeight,
        image,
      ),
      fadeOutDuration = fadeOutDuration ?? const Duration(milliseconds: 1000),
      fadeOutCurve = fadeOutCurve ?? Curves.easeOut,
      fadeInDuration = fadeInDuration ?? const Duration(milliseconds: 500),
      fadeInCurve = fadeInCurve ?? Curves.easeIn,
      alignment = alignment ?? Alignment.center,
      repeat = repeat ?? ImageRepeat.noRepeat,
      matchTextDirection = matchTextDirection ?? false,
      filterQuality = filterQuality ?? FilterQuality.low,
      placeholderFadeInDuration = placeholderFadeInDuration ?? Duration.zero,
      gaplessPlayback = gaplessPlayback ?? false,
      super(key: key);