flutter_use_battery 0.0.2 copy "flutter_use_battery: ^0.0.2" to clipboard
flutter_use_battery: ^0.0.2 copied to clipboard

outdated

Collection of Flutter Hooks.

flutter_use

flutter_lints
Inspired by react-use.



flutter pub add flutter_use

  • Sensors

    • useBattery — tracks device battery state. battery_plus
    • useGeolocation — tracks geo location and permission state of user's device. geolocator
    • useNetworkState — tracks the state of apps network connection. connectivity_plus
    • useAccelerometer, useUserAccelerometer, useGyroscope, and useMagnetometer — tracks accelerometer, gyroscope, and magnetometer sensors state of user's device. sensors_plus
    • 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. just_audio
    • useAssetVideo and useNetworkVideo — plays video, tracks its state, and exposes playback controls. video_player

  • Animations

    • useInterval — re-builds component on a set interval using Timer.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

    • useFutureRetryuseFuture with an additional retry method.
    • useDebounce — debounces a function.
    • useError — error dispatcher.
    • useException — exception dispatcher.

  • Lifecycles

    • useEffectOnce — a modified useEffect hook that only runs once.
    • useLifecycles — calls mount and unmount callbacks.
    • useLogger — logs in console as component goes through life-cycles.
    • useMount — calls mount callbacks.
    • useUnmount — calls unmount callbacks.
    • useUpdateEffect — run an effect only on updates.
    • useCustomCompareEffect — run an effect depending on deep comparison of its dependencies.

  • State

    • useDefault — returns the default value when state is null.
    • useLatest — returns the latest state or props.
    • usePreviousDistinct — like usePrevious but with a predicate to determine if previous should update.
    • 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 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 to useReducer.
    • useSetState — creates setState method which works like this.setState.
    • usePromise — resolves promise only while component is mounted.
    • useObservable — tracks latest value of an Observable.
    • useThrottle and useThrottleFn — throttles a function.



Unlicense — public domain.