flutter_use 0.0.1
flutter_use: ^0.0.1 copied to clipboard
Collection of Flutter Hooks.
- Sensors
useBattery
— tracks device battery state.useGeolocation
— tracks geo location state of user's device.useNetworkState
— tracks the state of browser's network connection.useAccelerometer
,useUserAccelerometer
,useGyroscope,
anduseMagnetometer
— tracks accelerometer, gyroscope, and magnetometer sensors state of user's device.
- UI
useScroll
— tracks a widget's scroll position.useScrolling
— tracks whether widget is scrolling.useFullscreen
— display an element or video full-screen.useAudio
— plays audio and exposes its controls.useAssetVideo
anduseNetworkVideo
— plays video, tracks its state, and exposes playback controls.
- Animations
useInterval
anduseHarmonicIntervalFn
— re-renders component on a set interval usingsetInterval
.useTimeout
— re-renders component after a timeout.useTimeoutFn
— calls given function after a timeout.
- Side-effects
useAsync
,useAsyncFn
, anduseAsyncRetry
— resolves anasync
function.useCopyToClipboard
— copies text to clipboard.useDebounce
— debounces a function.useError
— error dispatcher.useThrottle
anduseThrottleFn
— throttles a function.
- Lifecycles
useEffectOnce
— a modifieduseEffect
hook that only runs once.useEvent
— subscribe to events.useLifecycles
— callsmount
andunmount
callbacks.usePromise
— resolves promise only while component is mounted.useLogger
— logs in console as component goes through life-cycles.useUpdateEffect
— run aneffect
only on updates.useDeepCompareEffect
,useShallowCompareEffect
, anduseCustomCompareEffect
— run aneffect
depending on deep comparison of its dependencies
- State
useDefault
— returns the default value when state isnull
orundefined
.useLatest
— returns the latest state or propsusePreviousDistinct
— likeusePrevious
but with a predicate to determine ifprevious
should update.useObservable
— tracks latest value of anObservable
.useSetState
— createssetState
method which works likethis.setState
.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 an object.useSet
— tracks state of a Set.useQueue
— implements simple queue.useStateValidator
— tracks state of an object.useMultiStateValidator
— alike theuseStateValidator
, but tracks multiple states at a time.useMethods
— neat alternative touseReducer
.