flutter_hooks library Null safety

Classes

Hook<R>
Hook is similar to a StatelessWidget, but is not associated to an Element. [...]
HookBuilder
A HookWidget that defer its build to a callback
HookState<R, T extends Hook<R>>
The logic and internal state for a HookWidget
HookWidget
A Widget that can use Hook [...]
ObjectRef<T>
A class that stores a single value; [...]
StatefulHookWidget
A StatefulWidget that can use Hook [...]
Store<State, Action>
A state holder that allows mutations by dispatching actions.

Mixins

HookElement
An Element that uses a HookWidget as its configuration.

Constants

useTextEditingController → const _TextEditingControllerHookCreator
Creates a TextEditingController, either via an initial text or an initial TextEditingValue. [...]
_TextEditingControllerHookCreator()

Properties

debugHotReloadHooksEnabled bool
Wether to behave like in release mode or allow hot-reload for hooks. [...]
read / write

Functions

use<R>(Hook<R> hook) → R
Register a Hook and returns its value [...]
useAnimation<T>(Animation<T> animation) → T
Subscribes to an Animation and return its value. [...]
useAnimationController({Duration? duration, Duration? reverseDuration, String? debugLabel, double initialValue = 0, double lowerBound = 0, double upperBound = 1, TickerProvider? vsync, AnimationBehavior animationBehavior = AnimationBehavior.normal, List<Object?>? keys}) AnimationController
Creates an AnimationController automatically disposed. [...]
useAppLifecycleState() AppLifecycleState?
Returns the current AppLifecycleState value and rebuild the widget when it changes.
useCallback<T extends Function>(T callback, List<Object?> keys) → T
Cache a function accross rebuilds based on a list of keys. [...]
useContext() BuildContext
Obtain the BuildContext of the building HookWidget.
useEffect(Dispose? effect(), [List<Object?>? keys]) → void
Useful for side-effects and optionally canceling them. [...]
useFocusNode({String? debugLabel, FocusOnKeyCallback? onKey, bool skipTraversal = false, bool canRequestFocus = true, bool descendantsAreFocusable = true}) FocusNode
Creates and dispose of a FocusNode. [...]
useFuture<T>(Future<T>? future, {T? initialData, bool preserveState = true}) AsyncSnapshot<T>
Subscribes to a Future and return its current state in an AsyncSnapshot. [...]
useIsMounted() IsMounted
Returns an IsMounted object that you can use to check if the State is mounted. [...]
useListenable<T extends Listenable>(T listenable) → T
Subscribes to a Listenable and mark the widget as needing build whenever the listener is called. [...]
useMemoized<T>(T valueBuilder(), [List<Object?> keys = const <Object>[]]) → T
Cache the instance of a complex object. [...]
useOnAppLifecycleStateChange(LifecycleCallback? onStateChanged) → void
Listens to the AppLifecycleState.
usePageController({int initialPage = 0, bool keepPage = true, double viewportFraction = 1.0, List<Object?>? keys}) PageController
Creates and disposes a PageController. [...]
usePrevious<T>(T val) → T?
Returns the previous value passed to usePrevious (from the previous widget build).
useReassemble(VoidCallback callback) → void
Runs the callback on every hot reload similar to reassemble in the Stateful widgets [...]
useReducer<State, Action>(Reducer<State, Action> reducer, {required State initialState, required Action initialAction}) Store<State, Action>
An alternative to useState for more complex states. [...]
useRef<T>(T initialValue) ObjectRef<T>
Creates an object that contains a single mutable property. [...]
useScrollController({double initialScrollOffset = 0.0, bool keepScrollOffset = true, String? debugLabel, List<Object?>? keys}) ScrollController
Creates and disposes a ScrollController. [...]
useSingleTickerProvider({List<Object?>? keys}) TickerProvider
Creates a single usage TickerProvider. [...]
useState<T>(T initialData) ValueNotifier<T>
Creates a variable and subscribes to it. [...]
useStream<T>(Stream<T>? stream, {T? initialData, bool preserveState = true}) AsyncSnapshot<T>
Subscribes to a Stream and return its current state in an AsyncSnapshot. [...]
useStreamController<T>({bool sync = false, VoidCallback? onListen, VoidCallback? onCancel, List<Object?>? keys}) StreamController<T>
Creates a StreamController automatically disposed. [...]
useTabController({required int initialLength, TickerProvider? vsync, int initialIndex = 0, List<Object?>? keys}) TabController
Creates and disposes a TabController. [...]
useTransformationController({Matrix4? initialValue, List<Object?>? keys}) TransformationController
Creates and disposes a TransformationController. [...]
useValueChanged<T, R>(T value, R? valueChange(T oldValue, R? oldResult)) → R?
Watches a value and calls a callback whenever the value changed. [...]
useValueListenable<T>(ValueListenable<T> valueListenable) → T
Subscribes to a ValueListenable and return its value. [...]
useValueNotifier<T>(T initialData, [List<Object?>? keys]) ValueNotifier<T>
Creates a ValueNotifier automatically disposed. [...]

Typedefs

Dispose = void Function()
A function called when the state of a widget is destroyed.
IsMounted = bool Function()
Used by useIsMounted to allow widgets to determine if the widget is still in the widget tree or not.
LifecycleCallback = FutureOr<void> Function(AppLifecycleState? previous, AppLifecycleState current)
A callback to call when the app lifecycle changes.
Reducer<State, Action> = State Function(State state, Action action)
Composes an Action and a State to create a new State. [...]