get_it_hooks
library
Functions
-
pushScope({void init(GetIt getIt)?, void dispose()?, String? scopeName})
→ void
-
-
use<R>(Hook<R> hook)
→ R
-
Register a Hook and returns its value
-
useAllReady({void onReady(BuildContext context)?, void onError(BuildContext context, Object error)?, Duration? timeout})
→ bool
-
-
useAnimation<T>(Animation<T> animation)
→ T
-
Subscribes to an Animation and return its value.
-
useAnimationController({Duration? duration, 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.
-
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, {required T initialData, bool preserveState = true})
→ AsyncSnapshot<T>
-
Subscribes to a Future and return its current state in an AsyncSnapshot.
-
useFutureHandler<T extends Object, R>(Future<R> select(T), void handler(BuildContext context, AsyncSnapshot<R> newValue, void cancel()), {required R initialValue, String? instanceName, bool preserveState = true, bool executeImmediately = false})
→ void
-
-
useGet<T extends Object>({String? instanceName, dynamic param1, dynamic param2})
→ T
-
Not really hooks but convenients
-
useGetAsync<T extends Object>({String? instanceName, dynamic param1, dynamic param2})
→ Future<T>
-
like
get
but for async registrations
-
useGetIt<T extends Object>({String? instanceName, dynamic param1, dynamic param2})
→ T
-
-
useGetX<T extends Object, R>(R accessor(T), {String? instanceName})
→ R
-
like
get
but with an additional select
function to return a member of T
-
useIsMounted()
→ IsMounted
-
Returns an IsMounted object that you can use
to check if the State is mounted.
-
useIsReady<T extends Object>({void onReady(BuildContext context)?, void onError(BuildContext context, Object? error)?, Duration? timeout, String? instanceName})
→ bool
-
-
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.
-
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.
-
useRegisterHandler<T extends Object, R>(ValueListenable<R> select(T), void handler(BuildContext context, R newValue, void cancel()), {bool executeImmediately = false, String? instanceName})
→ void
-
-
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, {required 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.
-
useStreamHandler<T extends Object, R>(Stream<R> select(T), void handler(BuildContext context, AsyncSnapshot<R> newValue, void cancel()), {required R initialValue, String? instanceName, bool preserveState = true})
→ void
-
-
useTabController({required int initialLength, TickerProvider? vsync, int initialIndex = 0, List<Object?>? keys})
→ TabController
-
Creates and disposes a TabController.
-
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.
-
useWatch<T extends ValueListenable<R>, R>({String? instanceName})
→ R
-
-
useWatchFuture<T extends Object, R>(Future<R> select(T), R initialValue, {String? instanceName, bool preserveState = true})
→ AsyncSnapshot<R>
-
-
useWatchOnly<T extends Listenable, R>(R only(T), {String? instanceName})
→ R
-
-
useWatchStream<T extends Object, R>(Stream<R> select(T), R initialValue, {String? instanceName, bool preserveState = true})
→ AsyncSnapshot<R>
-
-
useWatchX<T extends Object, R>(ValueListenable<R> select(T), {String? instanceName})
→ R
-
-
useWatchXOnly<T extends Object, Q extends Listenable, R>(Q select(T), R only(Q listenable), {String? instanceName})
→ R
-
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.
-
Reducer<State, Action>
= State Function(State state, Action action)
-
Composes an
Action
and a State
to create a new State
.