DurableAnimationController constructor

DurableAnimationController({
  1. DurabilityPolicy policy = DurabilityPolicy.resume,
  2. double? value,
  3. Duration? duration,
  4. Duration? reverseDuration,
  5. String? debugLabel,
  6. double lowerBound = 0.0,
  7. double upperBound = 1.0,
  8. AnimationBehavior animationBehavior = AnimationBehavior.normal,
  9. 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 to lowerBound.
  • duration: Forward animation duration.
  • reverseDuration: Reverse animation duration.
  • debugLabel: Diagnostic label for debugging output.
  • lowerBound: Minimum animation value. Defaults to 0.0.
  • upperBound: Maximum animation value. Defaults to 1.0.
  • animationBehavior: Accessibility behavior override. Defaults to AnimationBehavior.normal.
  • clock: Timestamp supplier used when policy is DurabilityPolicy.catchUp. Defaults to DateTime.now.

Requires:

  • upperBound must be greater than or equal to lowerBound.

Ensures:

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,
      ),
  };
}