use<T> static method
Creates a hook that persists across rebuilds and hot reloads.
Hooks are stored by type and position in the setup function. During hot reload, hooks are matched by type and position to preserve state.
Parameters:
hook: A function that creates the hook value
Returns: The hook value (reused if already exists)
Throws: An assertion error if called outside of a SetupWidget
This is the underlying mechanism used by all use* hooks.
Implementation
@pragma('vm:prefer-inline')
@pragma('wasm:prefer-inline')
@pragma('dart2js:prefer-inline')
static T use<T>(SetupHook<T> hook) {
assert(JoltSetupContext.current != null,
'Hook.use must be called within a SetupWidget');
return JoltSetupContext.current!._useHook(hook);
}