removeCurrentSnackBar method

void removeCurrentSnackBar ({SnackBarClosedReason reason: SnackBarClosedReason.remove })

Removes the current SnackBar (if any) immediately.

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 }) {
  assert(reason != null);
  if (_snackBars.isEmpty)
    return;
  final Completer<SnackBarClosedReason> completer = _snackBars.first._completer;
  if (!completer.isCompleted)
    completer.complete(reason);
  _snackBarTimer?.cancel();
  _snackBarTimer = null;
  _snackBarController.value = 0.0;
}