animatedText method

AnimatedSwitcher animatedText({
  1. TextStyle? style,
  2. TextAlign? align,
  3. TextOverflow? overflow,
  4. int? maxLines,
  5. TextDirection? textDirection,
  6. Locale? locale,
  7. bool? softWrap,
  8. StrutStyle? strutStyle,
  9. Duration duration = const Duration(milliseconds: 100),
  10. Curve switchInCurve = Curves.easeIn,
  11. Curve switchOutCurve = Curves.easeOut,
  12. bool fade = true,
  13. bool scale = true,
  14. bool slide = false,
})

Returns an AnimatedSwitcher that animates text changes.

Implementation

AnimatedSwitcher animatedText({
  TextStyle? style,
  TextAlign? align,
  TextOverflow? overflow,
  int? maxLines,
  TextDirection? textDirection,
  Locale? locale,
  bool? softWrap,
  StrutStyle? strutStyle,
  Duration duration = const Duration(milliseconds: 100),
  Curve switchInCurve = Curves.easeIn,
  Curve switchOutCurve = Curves.easeOut,
  bool fade = true,
  bool scale = true,
  bool slide = false,
}) {
  return AnimatedSwitcher(
    duration: duration,
    transitionBuilder: (child, animation) {
      final slideOffset =
          slide
              ? Tween<Offset>(
                begin: const Offset(0.0, 1.0),
                end: Offset.zero,
              ).animate(animation)
              : null;
      final slideTransition =
          slide
              ? SlideTransition(position: slideOffset!, child: child)
              : child;

      final fadeTransition =
          fade
              ? FadeTransition(opacity: animation, child: slideTransition)
              : slideTransition;

      final scaleTransition =
          scale
              ? ScaleTransition(scale: animation, child: fadeTransition)
              : fadeTransition;
      return scaleTransition;
    },
    switchInCurve: switchInCurve,
    switchOutCurve: switchOutCurve,
    child: Text(
      this,
      key: Key(this),
      style: style,
      textAlign: align,
      overflow: overflow,
      maxLines: maxLines,
      textDirection: textDirection,
      locale: locale,
      softWrap: softWrap,
      strutStyle: strutStyle,
    ),
  );
}