draw method

  1. @override
void draw(
  1. Canvas canvas,
  2. Size size,
  3. bool deeper
)
override

绘制核心方法

  • deeper 当前是否为底层绘制
  • 出于性能考虑
  • 绘制过程为表层绘制,绘制完成抬起手指时会进行底层绘制

Implementation

@override
void draw(Canvas canvas, Size size, bool deeper) {
  for (int i = 1; i < points.length; i++) {
    canvas.drawPath(
      Path()
        ..moveTo(points[i - 1].dx, points[i - 1].dy)
        ..lineTo(points[i].dx, points[i].dy),
      paint.copyWith(
          strokeWidth: strokeWidthList[i], blendMode: BlendMode.src),
    );
  }
}