Drawing in Flutter using CustomPainter

<h1>Introduction :</h1> <p>In Flutter everything revolves around the term&nbsp;<strong>Widget.&nbsp;</strong>Flutter gives you the flexibility to write one code, create some beautiful UI widgets and the app is ready for both iOS and Android.So what actually happens is these widgets that you create are drawn on to your mobile screen Or we can call it as drawn on to the&nbsp;<strong><em>Canvas.&nbsp;</em></strong>Using the same concept we can draw on it and use it as a drawing board.</p> <p><img alt="" src="https://miro.medium.com/v2/resize:fit:294/1*Qodd3kD22dbhfazsgd0nJw.png" style="height:584px; width:294px" /></p> <p>We will be using&nbsp;<strong><em>custom painter</em>&nbsp;</strong>for drawing on the canvas, we will have options to change size, opacity and color of the marker.</p> <p>The code is available at&nbsp;<a href="https://github.com/sharansingh00002/draw" rel="noopener ugc nofollow" target="_blank">https://github.com/sharansingh00002/draw</a></p> <p>You can also checkout my video with extra code :p to take image for image drawn also :</p> <p><a href="https://www.youtube.com/watch?v=xHWAE8BNJ1E" rel="noopener ugc nofollow" target="_blank">https://www.youtube.com/watch?v=xHWAE8BNJ1E</a></p> <p>Now lets have a look at how this is done :)</p> <p><strong>CODE TIME</strong></p> <p>So the first information we need to have is the coordinates of the point on the canvas where the user has interacted with, which we can get simply by using Gesture Detector. We will be using&nbsp;<strong>onPanUpdate, onPanStart&nbsp;</strong>and<strong>&nbsp;onPanEnd&nbsp;</strong>properties of gesture detector.&nbsp;<strong><em>onPanStart</em></strong>&nbsp;is used when a user just clicks the screen, that way we can draw a single point but if user drags then the continuous points are obtained using the&nbsp;<strong><em>onPanUpdate&nbsp;</em></strong>and&nbsp;<strong><em>OnPanEnd&nbsp;</em></strong>is to notify user has stopped drawing.</p> <p>We will be storing the points in a list where each element will have the coordinates as well as paint properties associated with that point.</p> <p><a href="https://medium.com/flutter-community/drawing-in-flutter-using-custompainter-307a9f1c21f8">Click Here</a></p>