drawRotatedSquare method

void drawRotatedSquare({
  1. required Canvas canvas,
  2. required double size,
  3. required Offset offset,
  4. required double rotation,
  5. required Paint paint,
  6. bool flip = false,
})

Draws a Square Image rotated at offset around it's axis

Implementation

void drawRotatedSquare(
    {required Canvas canvas,
    required double size,
    required Offset offset,
    required double rotation,
    required Paint paint,
    bool flip = false}) {
  canvas
    ..save()
    ..translate(offset.dx, offset.dy);

  if (flip) {
    canvas.scale(-1, 1);
  }

  canvas
    ..rotate(flip ? -rotation : rotation)
    ..scale(size)
    ..drawImageRect(this, bounds(), kTargetRect, paint)
    ..restore();
}