I have this code:
AnimatedOpacity(
duration: Duration(seconds: 1),
opacity: _text == 'hide text'? 0 : 1,
child: Text(_text),
)
What is the easiest way to show old value of text (eg not 'hide text', but whatever is there before the text changes to this) for the duration of fading the text out?
You can create your own Widget to do what you need. I created a sample for you:
Result
Explanation
First, I created this code, where the main value is "show text", when the user press the button, the value will be updated to "hide text" and the animation will start.
There is a function
fadeBuilderthat you can use to validate when you want to hide the text, in this sample the condition to hide the text isvalue == 'hide text'Now this is the custom widget:
A new sample based on your requirements:
Result
Code: