applyTransform static method

void applyTransform(
  1. Canvas canvas,
  2. Size size
)

Applies the unit-square → cell transform for size to canvas (prefer this to pathFor: no allocation).

Implementation

static void applyTransform(Canvas canvas, Size size) {
  final scale = math.max(size.width, size.height);
  canvas
    ..translate((size.width - scale) / 2, (size.height - scale) / 2)
    ..scale(scale);
}