如何将动画重复一定次数?

How to repeat an animation certain number of time?

我有一个 AnimationController 对象,我想将一个动画重复 10 次。

AnimationController controller = ...;
controller.repeat(count: 10); // Wish there was something like this

注意:我不是在寻找解决方法,例如递归调用 controller.forward(from: 0) 10 次或 Timer.periodic,或保持计数 [=14] =],等等,然后停止动画。

感谢@pskink

您需要使用SawTooth曲线并设置count。例如:

FadeTransition(
  opacity: CurvedAnimation(parent: _controller, curve: SawTooth(10)), 
  child: SomeChild(),
);