ImageToo.memory constructor

ImageToo.memory(
  1. Uint8List bytes, {
  2. Key? key,
  3. double? width,
  4. double? height,
  5. BoxFit? fit,
  6. double scale = 1.0,
  7. AlignmentGeometry alignment = Alignment.center,
  8. Repeat repeat = Repeat.noRepeat,
  9. Offset mirrorOffset = Offset.zero,
  10. Color? color,
  11. BlendMode? colorBlendMode,
  12. Rect? centerSlice,
  13. bool matchTextDirection = false,
  14. bool gaplessPlayback = false,
  15. bool isAntiAlias = false,
  16. FilterQuality filterQuality = FilterQuality.low,
  17. String? semanticLabel,
  18. bool excludeFromSemantics = false,
  19. int? cacheWidth,
  20. int? cacheHeight,
  21. ImageFrameBuilder? frameBuilder,
  22. ImageErrorWidgetBuilder? errorBuilder,
})

A StatefulWidget that renders an image based on a list of data bytes representing that image in memory, the required Uint8List 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 BytesToTexture. It is used by calling one of the three methods
(one each for Repeat.mirror, Repeat.mirrorX, Repeat.mirrorY) on a Uint8List such as:

final Widget imageToo = Uint8List(...).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.memory(
  Uint8List bytes, {
  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, MemoryImage(bytes, scale: scale)),
      loadingBuilder = null,
      assert(cacheWidth == null || cacheWidth > 0),
      assert(cacheHeight == null || cacheHeight > 0),
      super(key: key);