ImageToo.file constructor
- File file, {
- Key? key,
- double? width,
- double? height,
- BoxFit? fit,
- double scale = 1.0,
- AlignmentGeometry alignment = Alignment.center,
- Repeat repeat = Repeat.noRepeat,
- Offset mirrorOffset = Offset.zero,
- Color? color,
- BlendMode? colorBlendMode,
- Rect? centerSlice,
- bool matchTextDirection = false,
- bool gaplessPlayback = false,
- bool isAntiAlias = false,
- FilterQuality filterQuality = FilterQuality.low,
- String? semanticLabel,
- bool excludeFromSemantics = false,
- int? cacheWidth,
- int? cacheHeight,
- ImageFrameBuilder? frameBuilder,
- ImageErrorWidgetBuilder? errorBuilder,
A StatefulWidget that renders an image from a File, the required value at the front of this constructor.
This image Widget
supports an expanded concept of ImageRepeat
defined
as Repeat.
Thus this ImageToo
can render an image smaller than its
bounds by mirror-tiling with
Repeat.mirror as well as the expected values such as Repeat.noRepeat,
Repeat.repeat, etc.
For convenience, consider FileToTexture. It is used by calling one of
the three methods
(one each for Repeat.mirror, Repeat.mirrorX, Repeat.mirrorY)
on a File
such as:
final Widget imageToo = File(...).toSeamlessTexture();
For a const ImageToo
, construct a new ImageToo
with an ImageProvider
as the image
property.
Like all package:img
classes, alignment
is ignored and forced Alignment.center
if repeat is set to Repeat.mirror, Repeat.mirrorX, Repeat.mirrorY.
- To align/position the seamlessly-tiling image in this situation,
employ an Offset in the mirrorOffset field. - This is a workaround for now and only aids in "aligning" a
Repeat.mirror
tiled image if it is meant to fill an entire space, shifting its edges.
Implementation
ImageToo.file(
File file, {
Key? key,
this.width,
this.height,
this.fit,
double scale = 1.0,
this.alignment = Alignment.center,
this.repeat = Repeat.noRepeat,
this.mirrorOffset = Offset.zero,
this.color,
this.colorBlendMode,
this.centerSlice,
this.matchTextDirection = false,
this.gaplessPlayback = false,
this.isAntiAlias = false,
this.filterQuality = FilterQuality.low,
this.semanticLabel,
this.excludeFromSemantics = false,
int? cacheWidth,
int? cacheHeight,
this.frameBuilder,
this.errorBuilder,
}) : image = ResizeImage.resizeIfNeeded(
cacheWidth, cacheHeight, FileImage(file, scale: scale)),
loadingBuilder = null,
assert(cacheWidth == null || cacheWidth > 0),
assert(cacheHeight == null || cacheHeight > 0),
super(key: key);