SubAnimationController constructor

SubAnimationController({
  1. Duration? duration,
  2. Duration? reverseDuration,
  3. String? debugLabel,
  4. double initialValue = 0,
  5. double lowerBound = 0,
  6. double upperBound = 1,
  7. TickerProvider? vsync,
  8. AnimationBehavior animationBehavior = AnimationBehavior.normal,
  9. required SubValueBuild<AnimationController> builder,
  10. SubValueKeys? keys,
})

Creates an AnimationController and automatically disposes it when necessary.

If no vsync is provided, the TickerProvider is implicitly obtained using a SubTickerProviderMixin.

Changing the duration parameter automatically updates the AnimationController.duration.

initialValue, lowerBound, upperBound and debugLabel are ignored after the first call.

Implementation

SubAnimationController({
  Duration? duration,
  Duration? reverseDuration,
  String? debugLabel,
  double initialValue = 0,
  double lowerBound = 0,
  double upperBound = 1,
  TickerProvider? vsync,
  AnimationBehavior animationBehavior = AnimationBehavior.normal,
  required super.builder,
  SubValueKeys? keys,
}) : super.builder(
        create: (context) => AnimationController(
          value: initialValue,
          vsync:
              vsync ?? (context as StatefulElement).state as TickerProvider,
          duration: duration,
          reverseDuration: reverseDuration,
          debugLabel: debugLabel,
          lowerBound: lowerBound,
          upperBound: upperBound,
          animationBehavior: animationBehavior,
        ),
        update: (context, previous) {
          if (previous.duration != duration) {
            previous.duration = duration;
          }
          if (previous.reverseDuration != reverseDuration) {
            previous.reverseDuration = reverseDuration;
          }
          return previous;
        },
        keys: keys != null ? (context) => keys : null,
        dispose: (context, value) => value.dispose(),
      );