Introduction to CustomPainter
Notes
In this lesson, we implement two classes:
TaskCompletionRing
as aStatelessWidget
RingPainter
as aCustomPainter
When implementing a CustomPainter
, we need to override the paint()
and shouldRepaint()
methods.
The paint()
method has two arguments:
- a
canvas
object that we can use to draw things - a
size
object that tells us how big is the drawing area
shouldRepaint()
should return true
when something has changed.
We can use an AspectRatio
to enforce a certain proportion of width to height (in this case: 1.0).
Here's a full tutorial on how to use CustomPainter
:
0 comments