paint method Null safety

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

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

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