render method
Implementation
@override
void render(Canvas canvas) {
if (!visible) return;
// Dim track — full width strip at screen top
canvas.drawRect(
size.toRect(),
Paint()..color = const Color(0x33FFFFFF),
);
if (fillAmount <= 0) return;
final fillW = size.x * fillAmount;
// Gradient fill: green → yellow → red mapped to the full track width
final shader = LinearGradient(
colors: _gradientColors,
stops: const [0.0, 0.5, 1.0],
).createShader(Rect.fromLTWH(0, 0, size.x, size.y));
canvas.drawRect(
Rect.fromLTWH(0, 0, fillW, size.y),
Paint()..shader = shader,
);
// Glow bloom when power is high
if (fillAmount > 0.6) {
final t = ((fillAmount - 0.6) / 0.4).clamp(0.0, 1.0);
canvas.drawRect(
Rect.fromLTWH(0, 0, fillW, size.y),
Paint()
..color = const Color(0xFFF44336).withValues(alpha: 0.45 * t)
..maskFilter = const MaskFilter.blur(BlurStyle.normal, 7),
);
}
// White needle at fill edge for precise timing feedback
if (fillAmount > 0.015 && fillAmount < 0.99) {
canvas.drawLine(
Offset(fillW, 0),
Offset(fillW, size.y),
Paint()
..color = Colors.white.withValues(alpha: 0.95)
..strokeWidth = 2.0,
);
}
}