read<G extends GetAny> static method
G
read<G extends GetAny>(})
This hook function returns a copy of the provided Get object, overriding it with any replacement in an ancestor GetScope if applicable.
Unlike Ref.watch, this method does not subscribe to any notifications from the object; instead, by default it creates a dependency on the ancestor scope (so that it receives notifications if a relevant Substitution is made).
Implementation
static G read<G extends GetAny>(
G get, {
bool createDependency = true,
bool throwIfMissing = false,
bool autoVsync = true,
}) {
final G result = GetScope.of(
useContext(),
get,
createDependency: createDependency,
throwIfMissing: throwIfMissing,
);
if (autoVsync) {
if (result case final GetVsyncAny getVsync) Ref.vsync(getVsync);
}
return result;
}