flutter_use 0.0.4 flutter_use: ^0.0.4 copied to clipboard
Collection of Flutter Hooks.
-
Sensors
useBattery
— tracks device battery state.useGeolocation
— tracks geo location and permission state of user's device.useNetworkState
— tracks the state of apps network connection.useAccelerometer
,useUserAccelerometer
,useGyroscope
, anduseMagnetometer
— tracks accelerometer, gyroscope, and magnetometer sensors state of user's device.useOrientation
— tracks state of device's screen orientation.useOrientationFn
— calls given function changed screen orientation of user's device.
-
UI
useAudio
— plays audio and exposes its controls.useAssetVideo
anduseNetworkVideo
— plays video, tracks its state, and exposes playback controls.
-
Animations
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
useFutureRetry
—useFuture
with an additional retry method.useDebounce
— debounces a function.useError
— error dispatcher.useException
— exception dispatcher.
-
Lifecycles
useEffectOnce
— a modifieduseEffect
hook that only runs once.useLifecycles
— callsmount
andunmount
callbacks.useLogger
— logs in console as component goes through life-cycles.useMount
— callsmount
callbacks.useUnmount
— callsunmount
callbacks.useUpdateEffect
— run aneffect
only on updates.useCustomCompareEffect
— run aneffect
depending on deep comparison of its dependencies.
-
State
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.useStateList
— circularly iterates over an array.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.useTextFormValidator
— tracks state of an object.useFirstMountState
— check if current build is first.useBuildsCount
— count component builds.
-
TBD
useCopyToClipboard
— copies text to clipboard.useEvent
— subscribe to events.useScroll
— tracks a widget's scroll position.useScrolling
— tracks whether widget is scrolling.useFullscreen
— display an element or video full-screen.useClickAway
— triggers callback when user clicks outside target area.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
.useThrottle
anduseThrottleFn
— throttles a function.
Unlicense — public domain.