close method

Future<void> close({
  1. bool withAnimations = true,
})

Close the snackbar with animation

Calling this on a snackbar that has already been closed is a no-op. Closing a snackbar that is still waiting in the queue cancels it, so it will never be displayed.

Implementation

Future<void> close({bool withAnimations = true}) async {
  if (_transitionCompleter.isCompleted) return;
  if (!withAnimations) {
    _removeOverlay();
    return;
  }
  _removeEntry();
  await future;
}