useAnimationController function

AnimationController useAnimationController({
  1. TickerProvider? vsync,
  2. Duration? duration,
  3. String? debugLabel,
  4. double? lowerBound,
  5. double? upperBound,
  6. double? value,
  7. AnimationBehavior animationBehavior = AnimationBehavior.normal,
})

Creates an AnimationController.

The controller is automatically disposed when the widget is unmounted.

Implementation

AnimationController useAnimationController({
  /// An optional [vsync] parameter to synchronize the animation.
  /// If not provided, a ticker will be created automatically.
  TickerProvider? vsync,
  Duration? duration,
  String? debugLabel,
  double? lowerBound,
  double? upperBound,
  double? value,
  AnimationBehavior animationBehavior = AnimationBehavior.normal,
}) {
  vsync ??= useSingleTickerState();
  final c = AnimationController(
    vsync: vsync,
    duration: duration,
    debugLabel: debugLabel,
    lowerBound: lowerBound ?? 0.0,
    upperBound: upperBound ?? 1.0,
    value: value,
    animationBehavior: animationBehavior,
  );
  onBeforeUnmount(c.dispose);
  return c;
}