mayNeedDispose method

  1. @override
void mayNeedDispose()
inherited

Life-cycle for when a listener is removed.

See also:

  • AutoDisposeProviderElementMixin, which overrides this method to destroy the state of a provider when no longer used.

Implementation

@override
void mayNeedDispose() {
  final links = _keepAliveLinks;

  // ignore: deprecated_member_use_from_same_package
  if (!maintainState && !hasListeners && (links == null || links.isEmpty)) {
    _container.scheduler.scheduleProviderDispose(this);
  }
}