getScopedValueResult<TResult, TScopedValue extends ScopedValue<TResult> > method
TResult
getScopedValueResult<TResult, TScopedValue extends ScopedValue<TResult> >(
- TScopedValue provider(), {
- void onInit(
- ScopedValueState<
TResult, TScopedValue> state
- ScopedValueState<
- void onUpdate(
- ScopedValueState<
TResult, TScopedValue> state
- ScopedValueState<
- bool listen = false,
- Object? 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
を取得し、その結果を返します。
listen
がtrue
の場合、ウィジェットに関連付けて変更を通知するようにします。
name
を指定すると型が同じ場合でも別のオブジェクトとして認識できるようにすることが可能です。
Implementation
TResult
getScopedValueResult<TResult, TScopedValue extends ScopedValue<TResult>>(
TScopedValue Function() provider, {
void Function(ScopedValueState<TResult, TScopedValue> state)? onInit,
void Function(ScopedValueState<TResult, TScopedValue> state)? onUpdate,
bool listen = false,
Object? name,
}) {
__listendBy ??= _listenedBy;
__managedBy ??= _managedBy;
final state = container.getScopedValueState<TResult, TScopedValue>(
provider,
onInit: (state) {
if (state.disposed) {
return;
}
_watched.add(state);
state._addListener(this, listen ? _callback : null);
state._sendLog(ScopedLoggerEvent.listen, additionalParameter: {
ScopedLoggerEvent.listenedKey: __listendBy,
});
onInit?.call(state);
},
onUpdate: (state) {
if (state.disposed) {
return;
}
_watched.add(state);
state._addListener(this, listen ? _callback : null);
onUpdate?.call(state);
},
name: name,
scope: _scope,
managedBy: __managedBy,
loggerAdapters: _appRef.loggerAdapters,
);
return state.build();
}