flutter_use 1.0.0
flutter_use: ^1.0.0 copied to clipboard
Essential Flutter hooks collection with 36 production-ready hooks for async operations, form management, UI interactions, and state management.
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.
π¦ Packages #
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 |
π Installation #
For the core package:
flutter pub add flutter_use
For specialized packages:
flutter pub add flutter_use_audio # Audio hooks
flutter pub add flutter_use_battery # Battery hooks
# ... and so on
π Interactive Demo Site #
Try out all hooks with live examples at: https://wasabeef.github.io/flutter_use/
π Hooks by Category #
π± Mobile-first Hooks #
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).
π State Management #
Core package: flutter_use
useToggle
anduseBoolean
β tracks state of a boolean.useCounter
anduseNumber
β 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
β likeusePrevious
but with a predicate to determine ifprevious
should update.useTextFormValidator
β reactive form validation with real-time feedback.
β±οΈ Timing & Animation #
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.
π Side Effects & Performance #
Core package: flutter_use
useFutureRetry
βuseFuture
with 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.
π― UI Interactions #
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.
β»οΈ Lifecycle Management #
Core package: flutter_use
useEffectOnce
β a modifieduseEffect
hook that only runs once.useLifecycles
β callsmount
andunmount
callbacks.useMount
β callsmount
callbacks.useUnmount
β callsunmount
callbacks.useUpdateEffect
β run aneffect
only on updates.useCustomCompareEffect
β run aneffect
depending on deep comparison of its dependencies.useFirstMountState
β check if current build is first.useBuildsCount
β count component builds.
π¨ Development & Debugging #
Core package: flutter_use
useLogger
β logs in console as component goes through life-cycles.
π± Device Sensors #
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.
π Device Information #
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.
π΅ Media #
Package: flutter_use_audio
useAudio
β plays audio and exposes its controls.
Package: flutter_use_video
useAssetVideo
anduseNetworkVideo
β plays video, tracks its state, and exposes playback controls.
π§ Coming Soon #
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
β createssetState
method which works likethis.setState
.usePromise
β resolves promise only while component is mounted.useObservable
β tracks latest value of anObservable
.
Unlicense β public domain.