paintInto method
Paints the drawing stretched onto destination.
The view box is mapped onto the destination rectangle without preserving the aspect ratio — device bodies declare a view box that already matches their target rectangle, and an exact mapping keeps the screen cut-out aligned with the simulated screen.
Implementation
void paintInto(
ui.Canvas canvas,
ui.Rect destination, {
ui.Color? currentColor,
}) {
if (shapes.isEmpty || viewBox.isEmpty || destination.isEmpty) {
return;
}
canvas.save();
canvas.translate(destination.left, destination.top);
canvas.scale(
destination.width / viewBox.width,
destination.height / viewBox.height,
);
canvas.translate(-viewBox.left, -viewBox.top);
paint(canvas, currentColor: currentColor);
canvas.restore();
}