Flutter & Dart (50 Qs)•Part 2: Core Architecture & Implementation (Mid-Level)
What is `CustomPainter` and how do you paint directly onto the Canvas?
senior LevelSystem Design
In Simple Words:
When no existing widget can render your design, CustomPainter gives you access to low-level graphics commands:
- Subclass
CustomPainterand implement:paint(Canvas canvas, Size size): Draw lines, circles, paths, arcs, gradients, and text.shouldRepaint(CustomPainter oldDelegate): Returntrueonly when parameters change, avoiding redundant GPU redraws.