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

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

TScopedValue by passing provider and returns the result.

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

name so that they can be recognized as different objects even if they have the same type.

providerを渡すことによりTScopedValueを取得し、その結果を返します。

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

nameを指定すると型が同じ場合でも別のオブジェクトとして認識できるようにすることが可能です。

Implementation

TResult
    getScopedValueResult<TResult, TScopedValue extends ScopedValue<TResult>>(
  TScopedValue Function() provider, {
  bool listen = false,
  String? name,
}) {
  __listendBy ??= _listenedBy;
  __managedBy ??= _managedBy;
  final state = container.getScopedValueState<TResult, TScopedValue>(
    provider,
    onInitOrUpdate: (state) {
      if (state.disposed) {
        return;
      }
      _watched.add(state);
      state._addListener(this, listen ? _callback : null);
      state._sendLog(ScopedLoggerEvent.listen, additionalParameter: {
        ScopedLoggerEvent.listenedKey: __listendBy,
      });
    },
    name: name,
    scope: _scope,
    managedBy: __managedBy,
    loggerAdapters: _appRef.loggerAdapters,
  );
  return state.build();
}