paint method Null safety

void paint(
  1. PaintingContext context,
  2. Offset offset,
  3. Size size,
  4. Image image,
  5. double pixelRatio
)

Called whenever the image that represents a RasterWidgets child should be painted.

The image is rasterized at the physical pixel resolution and should be scaled down by pixelRatio to account for device independent pixels.

There is no offset given in this paint method, as the parent is an OffsetLayer all offsets are Offset.zero.

The follow method shows how the default implementation of the delegate used by the RasterWidget paints the child image. This must account for the fact that the image width and height will be given in physical pixels, while the image must be painted with device independent pixels. That is, the width and height of the image is the widget and height of the provided size, multiplied by the pixelRatio:
void paint(PaintingContext context, Offset offset, Size size, ui.Image image, double pixelRatio) {
  final Rect src = Rect.fromLTWH(0, 0, image.width.toDouble(), image.height.toDouble());
  final Rect dst = Rect.fromLTWH(offset.dx, offset.dy, size.width, size.height);
  final Paint paint = Paint()
    ..filterQuality = FilterQuality.low;
  context.canvas.drawImageRect(image, src, dst, paint);
}

Implementation

void paint(PaintingContext context, Offset offset, Size size, ui.Image image, double pixelRatio);