hooks library
Declarative hooks for Flutter widgets.
This library provides convenient hooks for managing common Flutter resources like controllers, focus nodes, and lifecycle states with automatic cleanup. Designed to work with SetupWidget from jolt_flutter.
Classes
-
AsyncSnapshotFutureSignal<
T> - Interface for a signal that tracks a Future's state.
-
AsyncSnapshotStreamSignal<
T> - Interface for a signal that tracks a Stream's state.
- JoltEffectHookCreator
- Helper class for creating effect hooks in SetupWidget.
- JoltEffectScopeHookCreator
- Helper class for creating effect scope hooks in SetupWidget.
- JoltFlutterEffectHookCreator
- Helper class for creating Flutter effect hooks in SetupWidget.
- JoltSignalHookCreator
- Helper class for creating signal hooks in SetupWidget.
- JoltUseComputed
- Helper class for creating computed hooks in SetupWidget.
- JoltWatcherHookCreator
- Helper class for creating watcher hooks in SetupWidget.
Constants
- useRestorableTextEditingController → const _RestorableTextEditingControllerCreator
- useSignal → const JoltSignalHookCreator
- Creates a reactive signal hook with an initial value.
- useStreamController → const _StreamControllerCreator
- Creates a StreamController that is automatically closed when the widget is unmounted.
- useTextEditingController → const _TextEditingControllerCreator
Properties
- useAutomaticKeepAlive → _UseAutomaticKeepAliveCreator
-
Hook for controlling widget keep-alive behavior.
final
- useComputed → JoltUseComputed
-
Creates a computed value hook that derives from reactive dependencies.
final
- useEffect → JoltEffectHookCreator
-
Creates an effect hook that runs in response to reactive dependencies.
final
- useEffectScope → JoltEffectScopeHookCreator
-
Creates an effect scope hook for managing groups of effects.
final
- useFlutterEffect → JoltFlutterEffectHookCreator
-
Creates a Flutter effect hook that schedules execution at frame end.
final
- useWatcher → JoltWatcherHookCreator
-
Creates a watcher hook that observes specific reactive sources.
final
Functions
-
useAnimationController(
{TickerProvider? vsync, double? value, Duration? duration, Duration? reverseDuration, double lowerBound = 0.0, double upperBound = 1.0, AnimationBehavior animationBehavior = AnimationBehavior.normal}) → AnimationController - Creates an animation controller
-
useAppLifecycleState(
{AppLifecycleState? initialState, void onChange(AppLifecycleState state)?}) → ReadonlySignal< AppLifecycleState?> - Listens to application lifecycle state changes
-
useCarouselController(
{int initialItem = 0}) → CarouselController -
useChangeNotifier<
T extends ChangeNotifier> (T creator()) → T -
useContextMenuController(
{VoidCallback? onRemove}) → ContextMenuController -
useCupertinoTabController(
{int initialIndex = 0}) → CupertinoTabController -
useDraggableScrollableController(
) → DraggableScrollableController -
useExpansibleController(
) → ExpansibleController -
useFixedExtentScrollController(
{int initialItem = 0, void onAttach(ScrollPosition)?, void onDetach(ScrollPosition)?, bool keepScrollOffset = true, String? debugLabel}) → FixedExtentScrollController - Creates a fixed extent scroll controller
-
useFocusNode(
{String? debugLabel, KeyEventResult onKeyEvent(FocusNode, KeyEvent)?, bool skipTraversal = false, bool canRequestFocus = true, bool descendantsAreFocusable = true, bool descendantsAreTraversable = true}) → FocusNode - Creates a focus node
-
useFocusScopeNode(
{String? debugLabel, FocusOnKeyEventCallback? onKeyEvent, bool skipTraversal = false, bool canRequestFocus = true, TraversalEdgeBehavior traversalEdgeBehavior = TraversalEdgeBehavior.closedLoop, TraversalEdgeBehavior directionalTraversalEdgeBehavior = TraversalEdgeBehavior.stop}) → FocusScopeNode - Creates a focus scope node
-
useFuture<
T> (Future< T> ? future, {T? initialData}) → AsyncSnapshotFutureSignal<T> - Creates a reactive signal that tracks the state of a Future.
-
useJoltStream<
T> (Readable< T> value) → Stream<T> - Creates a stream hook from a reactive value.
-
useListenable<
T> (Listenable listenable, VoidCallback listener) → void - Subscribes to a Listenable and calls the listener when it notifies.
-
useListenableSync<
T, C extends Listenable> (Writable< T> node, C listenable, {required T getter(C listenable), void setter(T value)?}) → void - Subscribes to a Listenable and syncs it with a Writable node, optionally bidirectional.
-
useMagnifierController(
{AnimationController? animationController}) → MagnifierController -
useMenuController(
) → MenuController -
useOverlayPortalController(
{String? debugLabel}) → OverlayPortalController -
usePageController(
{int initialPage = 0, bool keepPage = true, double viewportFraction = 1.0, void onAttach(ScrollPosition)?, void onDetach(ScrollPosition)?}) → PageController - Creates a Page controller
-
useScrollController(
{double initialScrollOffset = 0.0, bool keepScrollOffset = true, String? debugLabel, ScrollControllerCallback? onAttach, ScrollControllerCallback? onDetach}) → ScrollController - Creates a scroll controller
-
useSearchController(
) → SearchController -
useSingleTickerProvider(
) → TickerProvider - Creates a single ticker provider
-
useSnapshotController(
{bool allowSnapshotting = false}) → SnapshotController -
useStream<
T> (Stream< T> ? stream, {T? initialData}) → AsyncSnapshotStreamSignal<T> - Creates a reactive signal that tracks the state of a Stream.
-
useStreamSubscription<
T> (Stream< T> stream, void onData(T event)?, {Function? onError, void onDone()?, bool? cancelOnError}) → void - Subscribes to a Stream and automatically cancels the subscription when the widget is unmounted.
-
useTabController(
{required int length, int initialIndex = 0, TickerProvider? vsync, Duration? animationDuration}) → TabController - Creates a Tab controller
-
useTickerProvider(
) → TickerProvider - Creates a ticker provider that can create multiple tickers
-
useTrackingScrollController(
{double initialScrollOffset = 0.0, bool keepScrollOffset = true, String? debugLabel, ScrollControllerCallback? onAttach, ScrollControllerCallback? onDetach}) → TrackingScrollController -
useTransformationController(
[Matrix4? value]) → TransformationController -
useTreeSliverController(
) → TreeSliverController -
useUndoHistoryController(
{UndoHistoryValue? value}) → UndoHistoryController -
useValueListenable<
T> (ValueListenable< T> listenable, void listener(T value)) → void - Subscribes to a ValueListenable and calls the listener when the value changes.
-
useValueNotifier<
T> (T initialValue) → ValueNotifier< T> - Creates a ValueNotifier that is automatically disposed when the widget is unmounted.
-
useWidgetStatesController(
[Set< WidgetState> ? value]) → WidgetStatesController