iDecode
iDecode

Reputation: 28906

How to repeat an animation certain number of time?

I have an AnimationController object and I want to repeat an animation 10 times.

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

Note: I'm not looking for workarounds, like calling controller.forward(from: 0) 10 times recursively or Timer.periodic, or keeping a count of AnimationController.animationStatus, etc and then stopping the animation.

Upvotes: 0

Views: 415

Answers (1)

iDecode
iDecode

Reputation: 28906

Thanks to @pskink.

You need to use SawTooth curve and set the count. For example:

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

Upvotes: 1

Related Questions