Img.asset constructor

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

A StatefulWidget that renders an image from an optional bundle AssetBundle that is defined by name, the required String 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 StringToTexture. It is used by calling one of the three methods
(one each for Repeat.mirror, Repeat.mirrorX, Repeat.mirrorY) on a String such as:

final Widget imageToo = 'res/image.png'.toSeamlessTexture(isAsset: true);

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

Img.asset(
  String name, {
  Key? key,
  AssetBundle? bundle,
  double? scale,
  double? width,
  double? height,
  BoxFit? fit,
  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,
  String? package,
  int? cacheWidth,
  int? cacheHeight,
  ImageFrameBuilder? frameBuilder,
  ImageErrorWidgetBuilder? errorBuilder,
}) : super.asset(
        name,
        key: key,
        bundle: bundle,
        frameBuilder: frameBuilder,
        errorBuilder: errorBuilder,
        semanticLabel: semanticLabel,
        excludeFromSemantics: excludeFromSemantics,
        scale: scale,
        width: width,
        height: height,
        color: color,
        colorBlendMode: colorBlendMode,
        fit: fit,
        alignment: alignment,
        repeat: repeat,
        mirrorOffset: mirrorOffset,
        centerSlice: centerSlice,
        matchTextDirection: matchTextDirection,
        gaplessPlayback: gaplessPlayback,
        isAntiAlias: isAntiAlias,
        package: package,
        filterQuality: filterQuality,
        cacheWidth: cacheWidth,
        cacheHeight: cacheHeight,
      );