removeToast static method

void removeToast({
  1. OverlayEntry? entry,
})

Implementation

static void removeToast({OverlayEntry? entry}) {
  if (entry != null && _toasts.contains(entry)) {
    // If this is the current persistent toast, clear the reference
    if (entry == _currentPersistentToast) {
      _currentPersistentToast = null;
    }

    _toasts.remove(entry);
    entry.remove();
  } else {
    // If no entry is provided, remove the last toast
    if (_toasts.isNotEmpty) {
      final lastToast = _toasts.last;
      _toasts.remove(lastToast);
      lastToast.remove();
    }
  }
}