useAnimationController function
AnimationController
useAnimationController({
- Duration? duration,
- Duration? reverseDuration,
- String? debugLabel,
- double initialValue = 0,
- double lowerBound = 0,
- double upperBound = 1,
- TickerProvider? vsync,
- AnimationBehavior animationBehavior = AnimationBehavior.normal,
- List<
Object?> ? keys,
Creates an AnimationController and automatically disposes it when necessary.
If no vsync
is provided, the TickerProvider is implicitly obtained using useSingleTickerProvider.
If a vsync
is specified, changing the instance of vsync
will result in a call to AnimationController.resync.
It is not possible to switch between implicit and explicit vsync
.
Changing the duration
parameter automatically updates the AnimationController.duration.
initialValue
, lowerBound
, upperBound
and debugLabel
are ignored after the first call.
See also:
- AnimationController, the created object.
- useAnimation, to listen to the created AnimationController.
Implementation
AnimationController useAnimationController({
Duration? duration,
Duration? reverseDuration,
String? debugLabel,
double initialValue = 0,
double lowerBound = 0,
double upperBound = 1,
TickerProvider? vsync,
AnimationBehavior animationBehavior = AnimationBehavior.normal,
List<Object?>? keys,
}) {
vsync ??= useSingleTickerProvider(keys: keys);
return use(
_AnimationControllerHook(
duration: duration,
reverseDuration: reverseDuration,
debugLabel: debugLabel,
initialValue: initialValue,
lowerBound: lowerBound,
upperBound: upperBound,
vsync: vsync,
animationBehavior: animationBehavior,
keys: keys,
),
);
}