OctoImage constructor
- Key? key,
- required ImageProvider<
Object> image, - OctoImageBuilder? imageBuilder,
- OctoPlaceholderBuilder? placeholderBuilder,
- OctoProgressIndicatorBuilder? progressIndicatorBuilder,
- OctoErrorBuilder? errorBuilder,
- Duration? fadeOutDuration,
- Curve? fadeOutCurve,
- Duration? fadeInDuration,
- Curve? fadeInCurve,
- double? width,
- double? height,
- BoxFit? fit,
- AlignmentGeometry? alignment,
- ImageRepeat? repeat,
- bool? matchTextDirection,
- Color? color,
- FilterQuality? filterQuality,
- BlendMode? colorBlendMode,
- Duration? placeholderFadeInDuration,
- bool? gaplessPlayback,
- int? memCacheWidth,
- 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({
super.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,
AlignmentGeometry? 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;