I know there is repeat()
method on AnimationController
but it always starts from the start.
Is there a built-in way to do one forward and one reverse animation, and to repeat that?
Thank you
A linear interpolation between a beginning and ending value. Tween is useful if you want to interpolate across a range. To use a Tween object with an animation, call the Tween object's animate method and pass it the Animation object that you want to modify.
The repeat
method supports the reverse
optional named argument, so you can write
animationController.repeat(reverse: true);
This is the modern, simple solution.
You can listen to the status of an animation using addStatusListener
. And on animation end reverse it.
final AnimationController c;
...
c.addStatusListener((status) {
if (status == AnimationStatus.completed) {
c.reverse();
}
else if (status == AnimationStatus.dismissed) {
c.forward();
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With