Advanced
Flutter
Q96 / 100
What is shouldRepaint() in CustomPainter and what should it return?
Correct! Well done.
Incorrect.
The correct answer is B) It compares the old and new painter to determine whether the canvas needs to be redrawn; return false when nothing has changed to avoid unnecessary work
B
Correct Answer
It compares the old and new painter to determine whether the canvas needs to be redrawn; return false when nothing has changed to avoid unnecessary work
Explanation
shouldRepaint() is called whenever a new CustomPainter instance is provided during a rebuild. Return true if the visual output depends on changed data (causing a repaint). Return false if nothing changed. Always returning true is correct but wasteful.
Progress
96/100