hideCurrentSnackBar method

void hideCurrentSnackBar({
  1. SnackBarClosedReason reason = SnackBarClosedReason.hide,
})

Removes the current SnackBar by running its normal exit animation.

The closed completer is called after the animation is complete.

Implementation

void hideCurrentSnackBar({ SnackBarClosedReason reason = SnackBarClosedReason.hide }) {
  if (_snackBars.isEmpty || _snackBarController!.isDismissed) {
    return;
  }
  final Completer<SnackBarClosedReason> completer = _snackBars.first._completer;
  if (_accessibleNavigation!) {
    _snackBarController!.value = 0.0;
    completer.complete(reason);
  } else {
    _snackBarController!.reverse().then<void>((void value) {
      assert(mounted);
      if (!completer.isCompleted) {
        completer.complete(reason);
      }
    });
  }
  _snackBarTimer?.cancel();
  _snackBarTimer = null;
}