use<R> static method
Register a Hook and returns its value
use must be called withing build
of either HookWidget or StatefulHookWidget,
and all calls to use must be made unconditionally, always on the same order.
See Hook for more explanations.
Implementation
@Deprecated('Use `use` instead of `Hook.use`')
static R use<R>(Hook<R> hook) {
assert(HookElement._currentHookElement != null, '''
Hooks can only be called from the build method of a widget that mix-in `Hooks`.
Hooks should only be called within the build method of a widget.
Calling them outside of build method leads to an unstable state and is therefore prohibited.
''');
return HookElement._currentHookElement!._use(hook);
}