createController method

AnimationController createController({
  1. required TickerProvider vsync,
  2. required Duration duration,
  3. bool repeat = true,
  4. bool reverse = false,
  5. VoidCallback? listener,
})

Creates and manages an AnimationController.

  • vsync: Ticker provider
  • duration: Duration of the animation
  • repeat: Whether the animation should repeat
  • reverse: Whether the animation should reverse
  • listener: Optional listener to be called on animation update

Implementation

AnimationController createController({
  required TickerProvider vsync,
  required Duration duration,
  bool repeat = true,
  bool reverse = false,
  VoidCallback? listener,
}) {
  final controller = AnimationController(vsync: vsync, duration: duration);

  if (repeat) {
    controller.repeat(reverse: reverse);
  } else {
    controller.forward();
  }

  if (listener != null) {
    controller.addListener(listener);
  }

  controllers.add(controller);
  return controller;
}