AnimationControllerLoopExtensions extension

Adds a loop extension on AnimationController identical to repeat but adding a count parameter specifying how many times to repeat before stopping:

  • count = null: the animation loops infinitely
  • count = 0: the animation won't play
  • count > 0: the animation will play count times

The total time will always be count * duration (or count * period if specified). Therefore, if reverse is true, one "count" is still considered animating in a single direction.

For example, the following would play forward (fade in) and back (fade out) once, then stop:

Text('Hello World').animate(
  onPlay: (controller) => controller.loop(
    reverse: true,
    count: 2,
  ),
).fadeIn();
on

Methods

loop({int? count, bool reverse = false, double? min, double? max, Duration? period}) TickerFuture