AnimatedText class
Texto animado que divide el string en partes y las anima en cascada.
Soporta múltiples tipos de animación (AnimationType) y modos de división (SplitType). La cascada se logra aumentando 100ms por elemento respecto a duration, generando un efecto secuencial (1, 2, 3, ...).
Cómo funciona
- El texto se separa según splitType:
char,wordoline. - Cada trozo se anima con
TweenAnimationBuilder, usando curve y duration- un offset incremental de 100ms por índice para la cascada.
- Si autoPlay es
true, la animación arranca al montar el widget. Para control manual, usa unGlobalKey<AnimatedTextState>y llama a AnimatedTextState.play.
Consejos de UX
AnimationType.fadees el más limpio y performante.AnimationType.blurluce brutal, pero implica más coste (post-procesado).- Con fuentes grandes o mucho contenido, considera reducir
blurFactory/o el número de elementos (usawordolineen vez dechar).
Ejemplo básico
AnimatedText(
text: 'Hello World',
splitType: SplitType.char,
animationType: AnimationType.fade,
curve: Curves.easeOut,
duration: const Duration(milliseconds: 500),
fontSize: 32,
autoPlay: true,
)
Ejemplo con control manual
final textKey = GlobalKey<AnimatedTextState>();
AnimatedText(
key: textKey,
text: 'Animated Text',
autoPlay: false,
animationType: AnimationType.rotate,
splitType: SplitType.word,
);
// Lanzar animación más tarde:
textKey.currentState?.play();
Ejemplo por líneas (subtítulos/versos)
AnimatedText(
text: 'Primera línea\nSegunda línea\nTercera línea',
splitType: SplitType.line,
animationType: AnimationType.rotateVertical,
duration: const Duration(milliseconds: 350),
fontSize: 20,
)
Notas
- El widget usa
Wrappara disposición fluida; si usasSplitType.linese inserta un\ntras cada trozo para conservar saltos. - Para reejecutar la cascada, llama a AnimatedTextState.play.
blurusaImageFiltered(puede afectar rendimiento en dispositivos modestos).
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- AnimatedText
Constructors
- AnimatedText({Key? key, String text = 'Animated Text', SplitType splitType = SplitType.char, Curve curve = Curves.bounceIn, double fontSize = 64, AnimationType animationType = AnimationType.fade, Duration duration = const Duration(milliseconds: 500), bool autoPlay = true, double blurFactor = 100})
-
Crea un AnimatedText.
const
Properties
- animationType → AnimationType
-
Tipo de animación a aplicar.
final
- autoPlay → bool
-
Si la animación debe iniciarse automáticamente.
final
- blurFactor → double
-
Factor de intensidad del desenfoque (solo para AnimationType.blur).
final
- curve → Curve
-
Curva de animación aplicada a cada elemento.
final
- duration → Duration
-
Duración base de la animación para cada elemento.
final
- fontSize → double
-
Tamaño de la fuente del texto.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- splitType → SplitType
-
Tipo de división del texto (caracteres, palabras o líneas).
final
- text → String
-
El texto a animar.
final
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< AnimatedText> -
Creates the mutable state for this widget at a given location in the tree.
override
-
debugDescribeChildren(
) → List< DiagnosticsNode> -
Returns a list of DiagnosticsNode objects describing this node's
children.
inherited
-
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Add additional properties associated with the node.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toDiagnosticsNode(
{String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode -
Returns a debug representation of the object that is used by debugging
tools and by DiagnosticsNode.toStringDeep.
inherited
-
toString(
{DiagnosticLevel minLevel = DiagnosticLevel.info}) → String -
A string representation of this object.
inherited
-
toStringDeep(
{String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) → String -
Returns a string representation of this node and its descendants.
inherited
-
toStringShallow(
{String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String -
Returns a one-line detailed description of the object.
inherited
-
toStringShort(
) → String -
A short, textual description of this widget.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited