getAlreadtExistsScopedValueResult<TResult, TScopedValue extends ScopedValue<TResult>> method

TResult? getAlreadtExistsScopedValueResult<TResult, TScopedValue extends ScopedValue<TResult>>({
  1. bool listen = false,
  2. String? name,
})

Retrieves the ScopedValueState associated with the TScopedValue already stored in the ScopedValueContainer and returns the result.

Returns Null if TScopedValue does not exist.

If TScopedValue was saved with name, specify the same name.

If listen is true, then it should be associated with the widget to notify it of changes.

ScopedValueState.setState, ScopedValueState.initValue and ScopedValueState.didUpdateValue are not executed.

ScopedValueContainerにすでに保存されているTScopedValueに関連するScopedValueStateを取得し、その結果を返します。

TScopedValueが存在しない場合はNullを返します。

nameを指定してTScopedValueを保存していた場合、同じnameを指定してください。

listentrueの場合、ウィジェットに関連付けて変更を通知するようにします。

ScopedValueState.setStateScopedValueState.initValueScopedValueState.didUpdateValueは実行されません。

Implementation

TResult? getAlreadtExistsScopedValueResult<TResult,
    TScopedValue extends ScopedValue<TResult>>({
  bool listen = false,
  String? name,
}) {
  final state =
      container.getAlreadyExistsScopedValueState<TResult, TScopedValue>(
    onInitOrUpdate: (state) {
      if (state.disposed) {
        return;
      }
      _watched.add(state);
      state._addListener(this, listen ? _callback : null);
    },
    name: name,
  );
  return state?.build();
}