Drawing Custom Shapes and Lines Using Canvas and Path in Flutter
Published in
6 min readMar 4, 2019
In order to draw custom shapes and lines in Flutter, there are basically four things involved:
- CustomPaint (It’s the exhibitor who gives you a paper to draw on, and then exhibits what you have drawn) 🖼️
- CustomPainter (It’s you! The painter!) 👨🎨
- Paint (It’s your brush) 🎨🖌️
- Canvas (It’s your paper) ⬜
Yes, it’s that simple!
So let’s get started by creating our main file:
The drawing will happen in the DrawingPage
class:
As usual, our page starts with Scaffold
which has an appBar
and a body
which is set to an instance of CustomPaint
widget.
The canvas is created and provided to you by the CustomPaint
widget which has three important properties:
painter
: This is an instance of theCustomPainter
class which draws the first layer of your painting on the…