onDispose method

  1. @override
void onDispose(
  1. void listener(

    Adds a listener to perform an operation right before the provider is destroyed.

    This typically happen when a provider marked with .autoDispose is no-longer used, or when ProviderContainer.dispose is called.

    See also:


    void onDispose(void Function() listener) {
      if (!_mounted) {
        throw StateError('Cannot call onDispose after a provider was dispose');
      _onDisposeListeners ??= DoubleLinkedQueue();