createAnimation<T> method

Animation<T> createAnimation<T>({
  1. required TickerProvider vsync,
  2. required AnimationController controller,
  3. required Tween<T> tween,
  4. VoidCallback? listener,
})

Creates and manages a tween-based Animation from a given controller.

If the tween is of type double, it will be stored in animations list to allow custom control or synchronization.

  • vsync: Ticker provider (not used directly, but for consistency)
  • controller: Animation controller
  • tween: Tween definition
  • listener: Optional listener on animation updates

Implementation

Animation<T> createAnimation<T>({
  required TickerProvider vsync,
  required AnimationController controller,
  required Tween<T> tween,
  VoidCallback? listener,
}) {
  final animation = tween.animate(controller);

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

  if (T == double) {
    animations.add(animation as Animation<double>);
  }

  return animation;
}