removeCurrentSnackBar method

void removeCurrentSnackBar(
  1. {SnackBarClosedReason reason = SnackBarClosedReason.remove}
)

Removes the current SnackBar (if any) immediately from registered Scaffolds.

The removed snack bar does not run its normal exit animation. If there are any queued snack bars, they begin their entrance animation immediately.

Implementation

void removeCurrentSnackBar({ SnackBarClosedReason reason = SnackBarClosedReason.remove }) {
  if (_snackBars.isEmpty) {
    return;
  }
  final Completer<SnackBarClosedReason> completer = _snackBars.first._completer;
  if (!completer.isCompleted) {
    completer.complete(reason);
  }
  _snackBarTimer?.cancel();
  _snackBarTimer = null;
  // This will trigger the animation's status callback.
  _snackBarController!.value = 0.0;
}