grow_hooks
library
Functions
-
useDisposableRef<T>(T instance, {dynamic onMount(T)?, dynamic onDispose(T)?})
→ T
-
Allows to call any cleanup/dispose functions on Singletons saved inside of
useRef hook.
-
useFormField([String? defaultValue])
→ (TextEditingController, FocusNode)
-
Simple Record wrapper around
useFocusNode and useTextEditingController hooks.
-
useHapticFeedback([HapticsType type = HapticsType.heavy])
→ VoidCallback
-
Wrapper hook around
haptic_feedback library.
-
useInterval(VoidCallback callback, Duration duration)
→ void
-
Periodically trigger a callback when duration elapses
Callback can be changed during the lifecycle, which it refresh the timer
Make sure that it's memoized correctly
-
useLocale()
→ Locale
-
return locale from Localizations provider
Throws in case Localizations provider is not found within the widget tree scope
-
useNavigatorPop<T>()
→ dynamic Function({T returnData})
-
Simple wrapper around Navigator.of(context).pop(); with generic return type support
-
useOnMount(VoidCallback callback)
→ void
-
Calls a provided callback after widget mounts into widget tree.
-
useOnPostFrameMount(VoidCallback callback)
→ void
-
Calls a provided callback after widget mounts into widget tree.
Difference between
useOnMount is that provided callback is wrapped inside addPostFrameCallback callback
-
useOnUnmount(VoidCallback cb)
→ void
-
Calls a provided callback before widget is unmounted from widget tree.
-
usePeriodicRerender(Duration duration, {bool isEnabled = true})
→ int
-
Periodically rerenders widget by internally incrementing
useState value.
Note that duration value can't be changed during the lifecycle of this hook.
-
usePostFrameEffect(VoidCallback callback, List<Object?>? keys)
→ void
-
Simple wrapper around
useEffect hook. The only difference that inner callback is wrapped inside addPostFrameCallback.
Note that since we are wrapping our callback inside addPostFrameCallback, there is no cleanup function support.
-
useRefValue<T>(T value)
→ T
-
Simple wrapper around
useRef, but emitting value instead of ObjectRef.
Use this in case you want a singleton instance of some class or other data structur.
-
useRerender()
→ (VoidCallback, int)
-
Forces widget rerender by internally incrementing
useState value.
-
useSyncedRef<T>(T value)
→ ObjectRef<T>
-
Automatically synchronizes changing value into
useRef hook.
Usefull in case you want to save some derived data inside of useRef, keeping previous value, etc..
-
useTimeout(VoidCallback callback, Duration duration)
→ void
-
Trigger a callback when duration elapses
-
useToggle({bool initial = false})
→ (bool, VoidCallback)
-
Easily manage a boolean state
-
useValueChangedCallback<T>(T value, dynamic valueChange())
→ void
-
Automatically calls a provided void callback when value changes.
Callback is not fired during the initial render.
-
useValueChangedHapticFeedback(Object? value, [HapticsType type = HapticsType.heavy])
→ void
-
Wrapper hook around
haptic_feedback library. Provides a haptic feedback anytime provided value changes.
Doesn't get called on initial render.