getAnimations method

  1. @override
List<CharacterAnimation> getAnimations(
  1. double progress,
  2. int charCount
)
override

Generates per-character color lerp from highlight band position.

Implementation

@override
List<CharacterAnimation> getAnimations(double progress, int charCount) {
  if (charCount == 0) return [];

  final curved = applyCurve(progress);

  return List.generate(charCount, (index) {
    final charPos = index / (charCount - 1).clamp(1, charCount);
    final returnT = sin(curved * pi);
    final highlightCenter = returnT;
    final dist = (charPos - highlightCenter).abs();
    final intensity = (1 - (dist / width)).clamp(0.0, 1.0);
    final color = Color.lerp(baseColor, highlightColor, intensity)!;
    return CharacterAnimation(color: color);
  });
}