onPaint method

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

Draws segment in series bounds.

Implementation

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

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

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

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

  final Paint connectorLinePaint = getConnectorLineStrokePaint();
  if (animationFactor == 1 &&
      points.isNotEmpty &&
      connectorLinePaint.strokeWidth > 0) {
    drawDashes(
      canvas,
      series.connectorLineSettings.dashArray,
      connectorLinePaint,
      start: points[0],
      end: points[1],
    );
  }
}