repeat method Null safety

TickerFuture repeat(
  1. {double? min,
  2. double? max,
  3. bool reverse = false,
  4. Duration? period}
)

Starts running this animation in the forward direction, and restarts the animation when it completes.

Defaults to repeating between the lowerBound and upperBound of the AnimationController when no explicit value is set for min and max.

With reverse set to true, instead of always starting over at min the starting value will alternate between min and max values on each repeat. The status will be reported as AnimationStatus.reverse when the animation runs from max to min.

Each run of the animation will have a duration of period. If period is not provided, duration will be used instead, which has to be set before repeat is called either in the constructor or later by using the duration setter.

Returns a TickerFuture that never completes. The TickerFuture.orCancel future completes with an error when the animation is stopped (e.g. with stop).

The most recently returned TickerFuture, if any, is marked as having been canceled, meaning the future never completes and its TickerFuture.orCancel derivative future completes with a TickerCanceled error.

Implementation

TickerFuture repeat({ double? min, double? max, bool reverse = false, Duration? period }) {
  min ??= lowerBound;
  max ??= upperBound;
  period ??= duration;
  assert(() {
    if (period == null) {
      throw FlutterError(
        'AnimationController.repeat() called without an explicit period and with no default Duration.\n'
        'Either the "period" argument to the repeat() method should be provided, or the '
        '"duration" property should be set, either in the constructor or later, before '
        'calling the repeat() function.',
      );
    }
    return true;
  }());
  assert(max >= min);
  assert(max <= upperBound && min >= lowerBound);
  assert(reverse != null);
  stop();
  return _startSimulation(_RepeatingSimulation(_value, min, max, reverse, period!, _directionSetter));
}