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.useAssetVideoanduseNetworkVideo— plays video, tracks its state, and exposes playback controls.
- Animations
useIntervalanduseHarmonicIntervalFn— 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 anasyncfunction.useCopyToClipboard— copies text to clipboard.useDebounce— debounces a function.useError— error dispatcher.useThrottleanduseThrottleFn— throttles a function.
- Lifecycles
useEffectOnce— a modifieduseEffecthook that only runs once.useEvent— subscribe to events.useLifecycles— callsmountandunmountcallbacks.usePromise— resolves promise only while component is mounted.useLogger— logs in console as component goes through life-cycles.useUpdateEffect— run aneffectonly on updates.useDeepCompareEffect,useShallowCompareEffect, anduseCustomCompareEffect— run aneffectdepending on deep comparison of its dependencies
- State
useDefault— returns the default value when state isnullorundefined.useLatest— returns the latest state or propsusePreviousDistinct— likeusePreviousbut with a predicate to determine ifpreviousshould update.useObservable— tracks latest value of anObservable.useSetState— createssetStatemethod which works likethis.setState.useStateList— circularly iterates over an array.useToggleanduseBoolean— tracks state of a boolean.useCounteranduseNumber— 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.