OctoImage.fromSet constructor

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

Creates an OctoWidget that displays an image with a predefined OctoSet. 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 octoSet should be set and contains all the information for the placeholder, error and image transformations.

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.fromSet({
  Key? key,
  required ImageProvider image,
  required OctoSet octoSet,
  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,
      ),
      imageBuilder = octoSet.imageBuilder,
      placeholderBuilder = octoSet.placeholderBuilder,
      progressIndicatorBuilder = octoSet.progressIndicatorBuilder,
      errorBuilder = octoSet.errorBuilder,
      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);