triggerAnimation method

  1. @override
Future<void>? triggerAnimation({
  1. bool restart = false,
})
override

Start animation.

If animation is completed (stopped at the upperBound) then the animation is reversed, and if the animation is dismissed (stopped at the lowerBound) then the animation is forwarded. IF animation is running nothing will happen.

You can force animation to restart from the lowerBound by setting the restart parameter to true.

You can start animation the conventional way using controller!.forward for example.

It returns Future that resolves when the started animation ends.

Implementation

@override
Future<void>? triggerAnimation({bool restart = false}) {
  if (restart) {
    animationEndFuture ??= Completer();
    repeatCount = null;
    _startAnimation(true);
    return animationEndFuture?.future;
  }
  if (!isAnimating) {
    animationEndFuture ??= Completer();
    _startAnimation(!shouldReverseRepeats);
  }
  return animationEndFuture?.future;
}