paint method

void paint(
  1. Canvas canvas,
  2. Rect rect
)

Paints the thumb onto the given canvas in the given rectangle.

Consider using radius and extension when deciding how large a rectangle to use for the thumb.

Implementation

void paint(Canvas canvas, Rect rect) {
  // Paint RRects instead of RSuperellipses here, because practically
  // [CupertinoSlider] only draws circular thumbs.
  final RRect thumbShape = RRect.fromRectAndRadius(
    rect,
    Radius.circular(rect.shortestSide / 2.0),
  );

  for (final BoxShadow shadow in shadows) {
    canvas.drawRRect(thumbShape.shift(shadow.offset), shadow.toPaint());
  }

  canvas.drawRRect(thumbShape.inflate(0.5), Paint()..color = _kThumbBorderColor);
  canvas.drawRRect(thumbShape, Paint()..color = color);
}