onPaint method

  1. @override
void onPaint(
  1. Canvas canvas
)
override

Draws segment in series bounds.

Implementation

@override
void onPaint(Canvas canvas) {
  if (points.isEmpty || segmentRect == null) {
    return;
  }

  final Rect? paintRect =
      Rect.lerp(_oldSegmentRect, segmentRect, animationFactor);
  Paint paint = getFillPaint();
  if (paint.color != Colors.transparent && !_isSameValue) {
    canvas.drawRect(paintRect!, paint);
  }

  paint = getStrokePaint();
  if (paint.color != Colors.transparent && paint.strokeWidth > 0) {
    Path strokePath;
    if (_isSameValue) {
      strokePath = Path()..addRect(paintRect!);
    } else {
      strokePath = strokePathFromRect(paintRect, paint.strokeWidth);
    }
    drawDashes(canvas, series.dashArray, paint, path: strokePath);

    final Offset start =
        Offset.lerp(_oldPoints[0], points[0], animationFactor)!;
    final Offset end =
        Offset.lerp(_oldPoints[1], points[1], animationFactor)!;
    drawDashes(canvas, series.dashArray, paint, start: start, end: end);

    final Offset start2 =
        Offset.lerp(_oldPoints[2], points[2], animationFactor)!;
    final Offset end2 =
        Offset.lerp(_oldPoints[3], points[3], animationFactor)!;
    drawDashes(canvas, series.dashArray, paint, start: start2, end: end2);
  }
}