InkImg constructor

InkImg(
  1. {Key? key,
  2. Color? color,
  3. required ImageProvider<Object> image,
  4. double scale = 1.0,
  5. double? width,
  6. double? height,
  7. EdgeInsets? padding,
  8. BoxFit? fit,
  9. AlignmentGeometry alignment = Alignment.center,
  10. Repeat repeat = Repeat.noRepeat,
  11. Offset mirrorOffset = Offset.zero,
  12. ColorFilter? colorFilter,
  13. Rect? centerSlice,
  14. bool matchTextDirection = false,
  15. Widget? child,
  16. ImageErrorListener? onImageError}
)

Creates a widget that shows an image (obtained from an ImageProvider) on a Material and whose underlying decoration supports the Repeat rendering modes including Repeat.mirror.

Also adds color capability, which would render underneath the image if provided.

This argument is a shorthand for passing a BoxDecoration that has only its BoxDecoration.image property (and potentially color) set to the Ink constructor. The properties of the DecorationImageToo of that BoxDecoration are set according to the arguments passed to this constructor.

The image argument must not be null. If there is no intention to render anything on this image, consider using a Container with a BoxDecoration.image instead. The onImageError argument may be provided to listen for errors when resolving the image.

The alignment, repeat, and matchTextDirection arguments must not be null either, but they have default values.

Like all package:img classes, alignment is ignored and forced Alignment.center if repeat is set to Repeat.mirror, Repeat.mirrorX, or 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 shifting a Repeat.mirror tiled image that is meant to fill an entire space.

See paintImageToo for a description of the meaning of these arguments.

(Description copied from Ink.image.)

Implementation

InkImg({
  Key? key,
  Color? color,
  required ImageProvider image,
  double scale = 1.0,
  double? width,
  double? height,
  EdgeInsets? padding,
  BoxFit? fit,
  AlignmentGeometry alignment = Alignment.center,
  Repeat repeat = Repeat.noRepeat,
  Offset mirrorOffset = Offset.zero,
  ColorFilter? colorFilter,
  Rect? centerSlice,
  bool matchTextDirection = false,
  Widget? child,
  ImageErrorListener? onImageError,
})  : assert(padding == null || padding.isNonNegative),
      super(
        key: key,
        padding: padding,
        decoration: BoxDecoration(
          color: color,
          image: DecorationImg(
            image: image,
            scale: scale,
            fit: fit,
            alignment: alignment,
            repeatMode: repeat,
            mirrorOffset: mirrorOffset,
            colorFilter: colorFilter,
            centerSlice: centerSlice,
            matchTextDirection: matchTextDirection,
            onError: onImageError,
          ),
        ),
        width: width,
        height: height,
        child: child,
      );