Skip to content

Instantly share code, notes, and snippets.

@jonahwilliams
Created December 2, 2022 20:03
Show Gist options
  • Save jonahwilliams/14df3fdcaa8f01b05f69ab83ba8dd7f8 to your computer and use it in GitHub Desktop.
Save jonahwilliams/14df3fdcaa8f01b05f69ab83ba8dd7f8 to your computer and use it in GitHub Desktop.
class ExpensivePainter extends CustomPainter {
@override
void paint(Canvas canvas, Size size) {
final double boxWidth = size.width / 50;
final double boxHeight = size.height / 50;
for (int i = 0; i < 50; i++) {
for (int j = 0; j < 50; j++) {
final Rect rect = Rect.fromLTWH(i * boxWidth, j * boxHeight, boxWidth, boxHeight);
canvas.drawRect(rect, Paint()
..style = PaintingStyle.fill
..color = Colors.red
);
}
}
}
@override
bool shouldRepaint(covariant CustomPainter oldDelegate) {
return false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment