paint method

void paint(
  1. Canvas canvas, {
  2. Color? currentColor,
})

Paints the drawing in its own view box coordinates.

currentColor tints every shape that inherited its fill (SvgShape.followsCurrentColor), preserving the shape's own opacity — what makes a single drawing usable as a status bar icon set whose color follows the system overlay style.

Implementation

void paint(ui.Canvas canvas, {ui.Color? currentColor}) {
  final ui.Paint paint = ui.Paint()..isAntiAlias = true;
  for (final SvgShape shape in shapes) {
    final ui.Color color = currentColor != null && shape.followsCurrentColor
        ? currentColor.withValues(alpha: currentColor.a * shape.color.a)
        : shape.color;
    if (shape.clips.isEmpty) {
      canvas.drawPath(shape.path, paint..color = color);
      continue;
    }
    canvas.save();
    for (final ui.Path clip in shape.clips) {
      canvas.clipPath(clip);
    }
    canvas.drawPath(shape.path, paint..color = color);
    canvas.restore();
  }
}