Drawing Custom Shapes and Lines Using Canvas and Path in Flutter

Meysam Mahfouzi
HackerNoon.com

--

In order to draw custom shapes and lines in Flutter, there are basically four things involved:

  1. CustomPaint (It’s the exhibitor who gives you a paper to draw on, and then exhibits what you have drawn) 🖼️
  2. CustomPainter (It’s you! The painter!) 👨‍🎨
  3. Paint (It’s your brush) 🎨🖌️
  4. 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:

  1. painter: This is an instance of the CustomPainter class which draws the first layer of your painting on the…

--

--