Flutter_use: Play Flutter Hooks
flutter pub add flutter_use
-
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.useAssetVideoanduseNetworkVideo— 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—useFuturewith an additional retry method.useDebounce— debounces a function.useError— error dispatcher.useException— exception dispatcher.
-
Lifecycles
useEffectOnce— a modifieduseEffecthook that only runs once.useLifecycles— callsmountandunmountcallbacks.useLogger— logs in console as component goes through life-cycles.useMount— callsmountcallbacks.useUnmount— callsunmountcallbacks.useUpdateEffect— run aneffectonly on updates.useCustomCompareEffect— run aneffectdepending on deep comparison of its dependencies.
-
State
useDefault— returns the default value when state isnull.useLatest— returns the latest state or props.usePreviousDistinct— likeusePreviousbut with a predicate to determine ifpreviousshould update.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 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— createssetStatemethod which works likethis.setState.usePromise— resolves promise only while component is mounted.useObservable— tracks latest value of anObservable.useThrottleanduseThrottleFn— throttles a function.
Unlicense — public domain.