A collection of Flutter Hooks inspired by React's react-use library. This monorepo contains multiple packages providing different categories of hooks for Flutter development.
| Package | Description | Version |
|---|---|---|
flutter_use |
Core hooks library with essential utilities | |
flutter_use_audio |
Audio playback and control hooks | |
flutter_use_battery |
Battery state monitoring hooks | |
flutter_use_geolocation |
Location and permission hooks | |
flutter_use_network_state |
Network connectivity hooks | |
flutter_use_sensors |
Device sensors hooks | |
flutter_use_video |
Video playbook hooks |
For the core package:
flutter pub add flutter_useFor specialized packages:
flutter pub add flutter_use_audio # Audio hooks
flutter pub add flutter_use_battery # Battery hooks
# ... and so onTry out all hooks with live examples at: https://wasabeef.github.io/flutter_use/
Core package: flutter_use
useAsyncβ manages async operations with loading, data, and error states.useDebounceFnβ debounces function calls for better performance.useInfiniteScrollβ implements infinite scrolling with automatic loading.useFormβ comprehensive form state management with validation.useKeyboardβ tracks keyboard visibility and manages layouts (mobile only).
Core package: flutter_use
useToggleanduseBooleanβ tracks state of a boolean.useCounteranduseNumberβ tracks state of a number.useListβ tracks state of an array.useMapβ tracks state of a map.useSetβ tracks state of a Set.useStateListβ circularly iterates over an array.useDefaultβ returns the default value when state isnull.useLatestβ returns the latest state or props.usePreviousDistinctβ likeusePreviousbut with a predicate to determine ifpreviousshould update.useTextFormValidatorβ reactive form validation with real-time feedback.
Core package: flutter_use
useIntervalβ re-builds component on a set interval usingTimer.periodic.useTimeoutβ re-builds component after a timeout.useTimeoutFnβ calls given function after a timeout.useUpdateβ returns a callback, which re-builds component when called.
Core package: flutter_use
useFutureRetryβuseFuturewith an additional retry method.useDebounceβ debounces a function.useThrottleβ throttles a value to update at most once per duration.useThrottleFnβ throttles a function to execute at most once per duration.useErrorβ error dispatcher.useExceptionβ exception dispatcher.
Core package: flutter_use
useScrollβ tracks a widget's scroll position.useScrollingβ tracks whether widget is scrolling.useClickAwayβ triggers callback when user clicks outside target area.useCopyToClipboardβ copies text to clipboard.
Core package: flutter_use
useEffectOnceβ a modifieduseEffecthook that only runs once.useLifecyclesβ callsmountandunmountcallbacks.useMountβ callsmountcallbacks.useUnmountβ callsunmountcallbacks.useUpdateEffectβ run aneffectonly on updates.useCustomCompareEffectβ run aneffectdepending on deep comparison of its dependencies.useFirstMountStateβ check if current build is first.useBuildsCountβ count component builds.
Core package: flutter_use
useLoggerβ logs in console as component goes through life-cycles.
Package: flutter_use_sensors
useAccelerometer,useUserAccelerometer,useGyroscope, anduseMagnetometerβ tracks accelerometer, gyroscope, and magnetometer sensors.
Core package: flutter_use
useOrientationβ tracks state of device's screen orientation.useOrientationFnβ calls given function when screen orientation changes.
Package: flutter_use_battery
useBatteryβ tracks device battery state.
Package: flutter_use_geolocation
useGeolocationβ tracks geo location and permission state of user's device.
Package: flutter_use_network_state
useNetworkStateβ tracks the state of apps network connection.
Package: flutter_use_audio
useAudioβ plays audio and exposes its controls.
Package: flutter_use_video
useAssetVideoanduseNetworkVideoβ plays video, tracks its state, and exposes playback controls.
useEventβ subscribe to events.useFullscreenβ display an element or video full-screen.usePageLeaveβ triggers when mouse leaves page boundaries.usePermissionβ query permission status for apps APIs.useMethodsβ neat alternative touseReducer.useSetStateβ createssetStatemethod which works likethis.setState.usePromiseβ resolves promise only while component is mounted.useObservableβ tracks latest value of anObservable.
Unlicense β public domain.
