createSpinController function

AnimationController createSpinController(
  1. TickerProvider vsync,
  2. VoidCallback onSpinComplete, {
  3. Duration duration = const Duration(seconds: 5),
})

Creates the AnimationController responsible for the spin, lasting duration (5 seconds by default).

Triggers onSpinComplete when the animation finishes.

Implementation

AnimationController createSpinController(
    TickerProvider vsync, VoidCallback onSpinComplete,
    {Duration duration = const Duration(seconds: 5)}) {
  AnimationController controller = AnimationController(
    vsync: vsync,
    duration: duration,
  );

  controller.addStatusListener((status) {
    if (status == AnimationStatus.completed) {
      onSpinComplete(); // Callback when spin finishes
    }
  });

  return controller;
}