dispose method

  1. @override
void dispose()
override

Release the resources associated to this ProviderElementBase.

This will be invoked when:

  • the provider is using autoDispose and it is no-longer used.
  • the associated ProviderContainer is disposed

On the other hand, this life-cycle will not be executed when a provider rebuilds.

As opposed to runOnDispose, this life-cycle is executed only for the lifetime of this element.

Implementation

@override
void dispose() {
  super.dispose();
  _notifierNotifier.result?.stateOrNull?._setElement(null);
}