hideCurrentSnackBar method Null safety

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 }) {
  assert(reason != null);
  if (_snackBars.isEmpty || _snackBarController!.status == AnimationStatus.dismissed) {
    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;
}