show static method

void show(
  1. BuildContext context,
  2. PrismToastMessage message
)

Shows an adaptive toast. Safe to call from anywhere with a BuildContext below a Navigator.

Implementation

static void show(BuildContext context, PrismToastMessage message) {
  final overlay = Overlay.maybeOf(context, rootOverlay: true);
  assert(overlay != null, 'PrismToast requires a Navigator/Overlay above.');
  if (overlay == null) return;

  _manager.add(_ToastSlot(message));
  if (_hostEntry == null) {
    _hostEntry = OverlayEntry(builder: (_) => _ToastHost(manager: _manager));
    overlay.insert(_hostEntry!);
  }
}