DurableAnimationController constructor
DurableAnimationController({
- DurabilityPolicy policy = DurabilityPolicy.resume,
- double? value,
- Duration? duration,
- Duration? reverseDuration,
- String? debugLabel,
- double lowerBound = 0.0,
- double upperBound = 1.0,
- AnimationBehavior animationBehavior = AnimationBehavior.normal,
- DateTime clock() = DateTime.now,
Creates a state-durable animation controller with bounded limits.
policy: The timeline durability policy across dormant deactivations. Defaults to DurabilityPolicy.resume.value: Initial value of the animation. Defaults tolowerBound.duration: Forward animation duration.reverseDuration: Reverse animation duration.debugLabel: Diagnostic label for debugging output.lowerBound: Minimum animation value. Defaults to0.0.upperBound: Maximum animation value. Defaults to1.0.animationBehavior: Accessibility behavior override. Defaults to AnimationBehavior.normal.clock: Timestamp supplier used whenpolicyis DurabilityPolicy.catchUp. Defaults to DateTime.now.
Requires:
upperBoundmust be greater than or equal tolowerBound.
Ensures:
- Returns a bounded DurableAnimationController governed by
policy.
Implementation
factory DurableAnimationController({
DurabilityPolicy policy = DurabilityPolicy.resume,
double? value,
Duration? duration,
Duration? reverseDuration,
String? debugLabel,
double lowerBound = 0.0,
double upperBound = 1.0,
AnimationBehavior animationBehavior = AnimationBehavior.normal,
DateTime Function() clock = DateTime.now,
}) {
assert(upperBound >= lowerBound);
return switch (policy) {
DurabilityPolicy.resume => _FrozenAnimationController(
value: value,
duration: duration,
reverseDuration: reverseDuration,
debugLabel: debugLabel,
lowerBound: lowerBound,
upperBound: upperBound,
animationBehavior: animationBehavior,
frozen: true,
),
DurabilityPolicy.catchUp => _CatchUpAnimationController(
value: value,
duration: duration,
reverseDuration: reverseDuration,
debugLabel: debugLabel,
lowerBound: lowerBound,
upperBound: upperBound,
animationBehavior: animationBehavior,
clock: clock,
),
DurabilityPolicy.reset => _FrozenAnimationController(
value: value,
duration: duration,
reverseDuration: reverseDuration,
debugLabel: debugLabel,
lowerBound: lowerBound,
upperBound: upperBound,
animationBehavior: animationBehavior,
frozen: false,
),
};
}