disposeControllers method

void disposeControllers()

Disposes all snackbar controllers and cleans up resources.

Uses Dart 3.8 pattern matching to handle the current snackbar disposal and cleans up remaining controllers.

Implementation

void disposeControllers() {
  // Handle current snackbar with pattern matching
  switch (_currentSnackbar) {
    case null:
      // No current snackbar, nothing to do here
      break;

    case var current:
      // Dispose current snackbar and remove from list
      current._removeOverlay();
      current._controller.dispose();
      _snackbarList.remove(current);
  }

  // Cancel all pending jobs
  _queue.cancelAllJobs();

  // Dispose remaining controllers and clear the list
  for (final controller in _snackbarList) {
    controller._controller.dispose();
  }
  _snackbarList.clear();
}