dispose method

void dispose()

Executed when the widget is destroyed.

ScopedValueState.dispose] is executed on the monitored ScopedValue and the retained ScopedValueContainer.

ウィジェットが破棄される際に実行します。

監視しているScopedValueと保持しているScopedValueContainerを対象にScopedValueState.disposeが実行されます。

Implementation

void dispose() {
  for (final watched in _watched) {
    if (watched.disposed) {
      continue;
    }
    watched._removeListener(this, _callback);
    watched._sendLog(ScopedLoggerEvent.unlisten, additionalParameter: {
      ScopedLoggerEvent.listenedKey: __listendBy,
    });
    watched.deactivate();
    if (watched.autoDisposeWhenUnreferenced && watched._listeners.isEmpty) {
      container.remove(watched);
    }
  }
  _watched.clear();
  if (_container != null) {
    _container!.dispose();
  }
}