cancel static method

void cancel()

Cancels the last displayed flushbar.

If there are no flushbars currently displayed, this method has no effect. This method removes the last displayed flushbar, effectively hiding it from the screen.

Throws an exception if FlashyProxy.buildContext is null.

Implementation

static void cancel() {
  if (FlashyProxy.buildContext == null) {
    throw Exception("FlashyProxy.buildContext is null, please use FlashyFlushbarProvider");
  }
  if (FlashyProxy.entries.isEmpty) return;
  final lastOverlayEntry = FlashyProxy.entries.values.last;
  if (lastOverlayEntry.mounted) {
    lastOverlayEntry.remove();
  }
  FlashyProxy.entries.remove(FlashyProxy.entries.keys.last);
}