resetAnimation method

  1. @override
void resetAnimation({
  1. Duration? duration,
  2. Duration? reverseDuration,
  3. Curve? curve,
  4. Curve? reverseCurve,
  5. int? repeats,
  6. bool? shouldReverseRepeats,
})
override

Used to change any of the global parameters fo the animation such as duration, reverseDuration, curve, reverseCurve, repeats and shouldReverseRepeats.

Change is taken instantaneously while the animation is playing

Implementation

@override
void resetAnimation({
  Duration? duration,
  Duration? reverseDuration,
  Curve? curve,
  Curve? reverseCurve,
  int? repeats,
  bool? shouldReverseRepeats,
}) {
  if (duration != null) {
    _controller?.duration = duration;
  }
  if (reverseDuration != null) {
    _controller?.reverseDuration = reverseDuration;
  }
  if (repeats != null) {
    this.repeats = repeats;
    repeatCount = null;
  }
  if (shouldReverseRepeats != null) {
    this.shouldReverseRepeats = shouldReverseRepeats;
    repeatCount = null;
  }
  bool isCurveChanged = false;
  if (curve != null) {
    this.curve = curve;
    isCurveChanged = true;
  }
  if (reverseCurve != null) {
    this.reverseCurve = reverseCurve;
    isCurveChanged = true;
  }
  if (isCurveChanged) {
    for (var fn in _resetAnimationListeners) {
      fn();
    }
    _curvedAnimation = null;
    _reverseCurvedAnimation = null;
  }
}