Custom painter is used to draw standard as well as custom shapes on the screen and is very powerful, it let’s you draw anything that you can think about.
All you need is a little imagination and a little maths.
Here is a simple basic quick run so you don’t need to worry about technicalities and get straight to painting.
In widget tree, we only have to add the CustomPaint widget and give it a painter.
Create MyCustomPainter class and add two required methods.
Paint method defines what we want to draw or paint on the canvas.
ShouldRepaint method defines when we want to repaint the canvas.
Shown below is a simple breakdown image of the canvas:
To draw a circle specify the center, radius and the color of the circle.
To draw a rectangle specify center height and width.