Last active
August 4, 2020 13:42
-
-
Save ravindu9701/01a6f5127851351d925370f3d9037f6e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DrawingPainter extends CustomPainter { | |
final List<Offset> points; | |
DrawingPainter(this.points); | |
final Paint _paint = Paint() | |
..strokeCap = StrokeCap.round | |
..color = Colors.blue | |
..strokeWidth = Constants.strokeWidth; | |
@override | |
void paint(Canvas canvas, Size size) { | |
for (int i = 0; i < points.length - 1; i++) { | |
if (points[i] != null && points[i + 1] != null) { | |
canvas.drawLine(points[i], points[i + 1], _paint); | |
} | |
} | |
} | |
@override | |
bool shouldRepaint(CustomPainter oldDelegate) { | |
return true; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment