2

I want to animate my Text widget when it's content changes. Is there a way to do it without having two seperate Text widgets?

To make it clear, I have an authentication screen where I change a Text widget from Login to Register or vice versa. This should be animated smoothly in a fade transition.

Text('${_mode == AuthMode.Register ? 'Register' : 'Login'}', 
     style: Theme.of(context).textTheme.title),

Of course I could just simply make two Text widgets and fade the one in and the other one out. But is there a simpler way?

Kind Regards, pichlerAT

pichlerAT
  • 23
  • 1
  • 3

1 Answers1

1

For fade in/out between two widgets, check this

https://api.flutter.dev/flutter/widgets/AnimatedCrossFade-class.html

Hian
  • 1,462
  • 7
  • 6
  • 1
    it uses first child and second child as arguments for animation, But I have a few texts to use. – Shanu May 05 '23 at 05:10