class DrawPainting extends CustomPainter {
List<Offset> points = [];
Canvas _lastCanvas;
Size _lastSize;
DrawPainting(points){
this.points = points;
}
void paint(Canvas canvas, Size size) {
print({"the main paint is called .... ": {"size" : size}});
_lastCanvas = canvas;
_lastSize = size;
Paint paint = new Paint()
..color = Colors.black
..strokeCap = StrokeCap.round
..strokeWidth = 8.0;
for (int i = 0; i < points.length - 1; i++) {
if (points[i] != null &&
points[i + 1] != null &&
(points[i].dx >= 0 &&
points[i].dy >= 0 &&
points[i].dx < size.width &&
points[i].dy < size.height) &&
(points[i + 1].dx >= 0 &&
points[i + 1].dy >= 0 &&
points[i + 1].dx < size.width &&
points[i + 1].dy < size.height)){
canvas.drawLine(points[i], points[i + 1], paint);
}
}
}
bool shouldRepaint(DrawPainting other) => other.points != points;
}