animatedBuilder method

  1. @override
Widget animatedBuilder(
  1. BuildContext context,
  2. Widget? child
)
override

Widget showing animated text, based on animation value(s).

Implementation

@override
Widget animatedBuilder(context, child) {
  // get the count / text text length base from the animation value
  final count = (_scrambleText.value * textCharacters.length).round();

  return RichText(
    text: TextSpan(
      children: List.generate(
        count,
        (index) {
          return WidgetSpan(
            child: ScrambledChar(
              char: textCharacters.elementAt(index),
              scrambleDuration: speed,
              style: textStyle,
            ),
          );
        },
      ),
    ),
  );
}