Introduction to CustomPainter

Notes

In this lesson we implement two classes:

  • TaskCompletionRing as a StatelessWidget
  • RingPainter as a CustomPainter

When implementing a CustomPainter, we need to override the paint() and shouldRepaint() methods.

The paint() method has two arguments:

  • canvas object that we can use to draw things
  • 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:


Discussion

0 comments