initAnimation method
Initialize the Animation.
Implementation
@override
void initAnimation(AnimationController controller) {
// Note: This calculation is the only reason why [textStyle] is required
final tuning = (300.0 * colors.length) *
(textStyle!.fontSize! / 24.0) *
0.75 *
(textCharacters.length / 15.0);
_fadeIn = Tween<double>(begin: 0.0, end: 1.0).animate(
CurvedAnimation(
parent: controller,
curve: const Interval(0.0, 0.1, curve: Curves.easeOut),
),
);
_fadeOut = Tween<double>(begin: 1.0, end: 1.0).animate(
CurvedAnimation(
parent: controller,
curve: const Interval(0.9, 1.0, curve: Curves.easeIn),
),
);
final colorShift = colors.length * tuning;
final colorTween = textDirection == TextDirection.ltr
? Tween<double>(
begin: 0.0,
end: colorShift,
)
: Tween<double>(
begin: colorShift,
end: 0.0,
);
_colorShifter = colorTween.animate(
CurvedAnimation(
parent: controller,
curve: const Interval(0.0, 1.0, curve: Curves.easeIn),
),
);
// With RTL, colors need to be reversed to compensate for colorTween
// counting down instead of up.
_colors = textDirection == TextDirection.ltr
? colors
: colors.reversed.toList(growable: false);
}