onPaint method

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

Draws segment in series bounds.

Implementation

@override
void onPaint(Canvas canvas) {
  if (series.isTrackVisible) {
    // Draws the tracker bounds.
    super.onPaint(canvas);
  }

  if (segmentRect == null) {
    return;
  }

  final RRect? paintRRect =
      RRect.lerp(_oldSegmentRect, segmentRect, animationFactor);
  if (paintRRect == null || paintRRect.isEmpty) {
    return;
  }

  Paint paint = getFillPaint();
  if (paint.color != Colors.transparent) {
    canvas.drawRRect(paintRRect, paint);
  }

  paint = getStrokePaint();
  final double strokeWidth = paint.strokeWidth;
  if (paint.color != Colors.transparent && strokeWidth > 0) {
    final Path strokePath = strokePathFromRRect(segmentRect, strokeWidth);
    drawDashes(canvas, series.dashArray, paint, path: strokePath);
  }
}