select<Result, T> static method
Result
select<Result, T>(})
Selects a value from a complex Get object and triggers a rebuild when the selected value changes.
Multiple values can be selected by returning a Record type.
Must be called inside a HookWidget.build method.
Notifications are not sent when watching is false
(changes to this value will apply the next time the HookWidget
is built).
If a GetVsync object is passed, this hook will check if the
Vsync is attached to a BuildContext (which is typically achieved
via Ref.vsync) and throws an error if it fails. The check can be
bypassed by setting checkVsync to false.
By default, if an ancestor GetScope overrides the Get object's
value, the new object is used instead. Setting useScope to false
will ignore any overrides.
Implementation
static Result select<Result, T>(
GetT<T> get,
Result Function(T value) selector, {
bool watching = true,
bool autoVsync = true,
bool useScope = true,
}) {
if (useScope) get = GetScope.of(useContext(), get);
return HookData.use(
_GetSelect<Result, T>(get.hooked, selector, watching: watching),
debugLabel: 'Ref.select',
);
}