removeToast method

void removeToast(
  1. String toastId
)

Called when a toast should be removed (timer or widget dismiss).

Implementation

void removeToast(String toastId) {
  final idx = _activeToasts.indexWhere((e) => e.id == toastId);
  if (idx == -1) return;

  final entry = _activeToasts.removeAt(idx);
  entry.timer?.cancel();
  _timerStartTimes.remove(toastId);
  _pausedTimerRemaining.remove(toastId);

  if (entry.config.preventDuplicates) {
    _duplicateKeys.remove(entry.config.key);
  }

  if (_queuedToasts.isNotEmpty && _activeToasts.length < maxVisible) {
    final next = _queuedToasts.removeAt(0);
    _showToast(next);
  }

  _refreshContainer();
  _removeContainerIfEmpty();
}