repeat method

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

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.

If a value is passed to count, the animation will perform that many iterations before stopping. Otherwise, the animation repeats indefinitely.

Returns a TickerFuture that never completes, unless a count is specified. 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,
  int? count,
}) {
  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(count == null || count > 0, 'Count shall be greater than zero if not null');
  stop();
  return _startSimulation(_RepeatingSimulation(_value, min, max, reverse, period!, _directionSetter, count));
}