flutter_use 0.0.1 copy "flutter_use: ^0.0.1" to clipboard
flutter_use: ^0.0.1 copied to clipboard

outdated

Collection of Flutter Hooks.

flutter_use

flutter_lints
Inspired by react-use.


  • Sensors
    • useBattery — tracks device battery state. battery_plus
    • useGeolocation — tracks geo location state of user's device. geolocator
    • useNetworkState — tracks the state of browser's network connection. connectivity_plus
    • useAccelerometer, useUserAccelerometer, useGyroscope, and useMagnetometer — tracks accelerometer, gyroscope, and magnetometer sensors state of user's device. sensors_plus

  • 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. just_audio
    • useAssetVideo and useNetworkVideo — plays video, tracks its state, and exposes playback controls. video_player

  • Animations
    • useInterval and useHarmonicIntervalFn — re-renders component on a set interval using setInterval.
    • useTimeout — re-renders component after a timeout.
    • useTimeoutFn — calls given function after a timeout.

  • Side-effects
    • useAsync, useAsyncFn, and useAsyncRetry — resolves an async function.
    • useCopyToClipboard — copies text to clipboard.
    • useDebounce — debounces a function.
    • useError — error dispatcher.
    • useThrottle and useThrottleFn — throttles a function.

  • Lifecycles
    • useEffectOnce — a modified useEffect hook that only runs once.
    • useEvent — subscribe to events.
    • useLifecycles — calls mount and unmount callbacks.
    • usePromise — resolves promise only while component is mounted.
    • useLogger — logs in console as component goes through life-cycles.
    • useUpdateEffect — run an effect only on updates.
    • useDeepCompareEffect, useShallowCompareEffect, and useCustomCompareEffect — run an effect depending on deep comparison of its dependencies

  • State
    • useDefault — returns the default value when state is null or undefined.
    • useLatest — returns the latest state or props
    • usePreviousDistinct — like usePrevious but with a predicate to determine if previous should update.
    • useObservable — tracks latest value of an Observable.
    • useSetState — creates setState method which works like this.setState.
    • useStateList — circularly iterates over an array.
    • useToggle and useBoolean — tracks state of a boolean.
    • useCounter and useNumber — 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 the useStateValidator, but tracks multiple states at a time.
    • useMethods — neat alternative to useReducer.