[英]How to do yoyo animation in flutter?
I know there is repeat()
method on AnimationController
but it always starts from the start.我知道
AnimationController
上有repeat()
方法,但它总是从头开始。
Is there a built-in way to do one forward and one reverse animation, and to repeat that?有没有内置的方法来做一个正向和一个反向动画,并重复它?
Thank you谢谢
You can listen to the status of an animation using addStatusListener
.您可以使用
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();
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.