draw method

  1. @override
void draw(
  1. Canvas canvas,
  2. Size size,
  3. DrafterThemeColors theme,
  4. double progress,
)
override

Draws the chart. progress is the entrance reveal in 0..1 (1 = fully drawn).

Implementation

@override
void draw(
  Canvas canvas,
  Size size,
  DrafterThemeColors theme,
  double progress,
) {
  final layout = _layoutCells(size);
  final cornerRadius = layout.cornerRadius;

  // Fade the whole grid in with the reveal progress.
  final alpha = progress.clamp(0.0, 1.0);

  for (final c in layout.cells) {
    final color = _contributionColor(c.count, theme);
    canvas.drawRRect(
      RRect.fromRectAndRadius(c.rect, Radius.circular(cornerRadius)),
      Paint()..color = color.withValues(alpha: color.a * alpha),
    );
  }
}