drawObject method

  1. @override
void drawObject(
  1. Canvas canvas,
  2. Size size
)
override

Draws the image on the provided canvas of size size.

Implementation

@override
void drawObject(Canvas canvas, Size size) {
  final scaledSize =
      Offset(image.width.toDouble(), image.height.toDouble()) * scale;
  final position = this.position.scale(flipped ? -1 : 1, 1);

  if (flipped) canvas.scale(-1, 1);

  // Draw the image onto the canvas.
  canvas.drawImageRect(
      image,
      Rect.fromPoints(Offset.zero,
          Offset(image.width.toDouble(), image.height.toDouble())),
      Rect.fromPoints(position - scaledSize / 2, position + scaledSize / 2),
      Paint());
}