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) {
  final rrect = RRect.fromRectAndRadius(
    rect,
    Radius.circular(rect.shortestSide / 2.0),
  );

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

  canvas
    ..drawRRect(
      rrect.deflate(1.8),
      Paint()..color = _kThumbBorderColor,
    )
    ..drawRRect(rrect.deflate(2.3), Paint()..color = color);
}