cancel method

void cancel()

Resets the speed of the fade-out animation to the speed corresponding to the defined action and forces the effect to fade out. In some cases, it cancels the effect altogether.

Implementation

void cancel() {
  // Cannot perform the animation task without all animation-related
  // instances being initialized.
  if (!isInitialized) return;

  _fadeAnimation.reverseDuration = behavior.cancelDuration;
  _fadeCurved.reverseCurve = behavior.cancelCurve;
  _fadeAnimation.reverse();

  switch (context.cancelBehavior) {
    case TouchRippleCancelBehavior.none:
      break;
    case TouchRippleCancelBehavior.stop:
      _spreadAnimation.stop();
      break;
    case TouchRippleCancelBehavior.reverse:
      _spreadAnimation.reverse();
      break;
  }
}