hideCurrentMaterialBanner method

void hideCurrentMaterialBanner({
  1. MaterialBannerClosedReason reason = MaterialBannerClosedReason.hide,
})

Removes the current MaterialBanner by running its normal exit animation.

The closed completer is called after the animation is complete.

Implementation

void hideCurrentMaterialBanner({ MaterialBannerClosedReason reason = MaterialBannerClosedReason.hide }) {
  if (_materialBanners.isEmpty || _materialBannerController!.isDismissed) {
    return;
  }
  final Completer<MaterialBannerClosedReason> completer = _materialBanners.first._completer;
  if (_accessibleNavigation!) {
    _materialBannerController!.value = 0.0;
    completer.complete(reason);
  } else {
    _materialBannerController!.reverse().then<void>((void value) {
      assert(mounted);
      if (!completer.isCompleted) {
        completer.complete(reason);
      }
    });
  }
}