HooksContextExtension extension
Provides a suite of custom hooks via BuildContext to manage the lifecycle of common Flutter controllers and resource-heavy objects automatically.
- on
Methods
-
onDispose(
VoidCallback callback) → void -
Available on BuildContext, provided by the HooksContextExtension extension
Runs the initially registeredcallbackwhen this widget is removed. -
onInitState(
VoidCallback callback) → void -
Available on BuildContext, provided by the HooksContextExtension extension
Runscallbackonce when first registered by this widget. -
setState<
T extends Widget> ([VoidCallback? callback]) → void -
Available on BuildContext, provided by the HooksContextExtension extension
Runscallbackand marks a widget for rebuilding. -
useAnimationController(
{double? value, Duration? duration, Duration? reverseDuration, String? debugLabel, double lowerBound = 0.0, double upperBound = 1.0, AnimationBehavior animationBehavior = .normal, TickerProvider? vsync}) → AnimationController -
Available on BuildContext, provided by the HooksContextExtension extension
Creates and automatically disposes an AnimationController. -
useFocusNode(
{String? debugLabel, FocusOnKeyEventCallback? onKeyEvent, bool skipTraversal = false, bool canRequestFocus = true, bool descendantsAreFocusable = true, bool descendantsAreTraversable = true}) → FocusNode -
Available on BuildContext, provided by the HooksContextExtension extension
Creates and automatically disposes a FocusNode. -
usePageController(
{int initialPage = 0, bool keepPage = true, double viewportFraction = 1.0, ScrollControllerCallback? onAttach, ScrollControllerCallback? onDetach}) → PageController -
Available on BuildContext, provided by the HooksContextExtension extension
Creates and automatically disposes a PageController. -
useScrollController(
{double initialScrollOffset = 0.0, bool keepScrollOffset = true, String? debugLabel, ScrollControllerCallback? onAttach, ScrollControllerCallback? onDetach}) → ScrollController -
Available on BuildContext, provided by the HooksContextExtension extension
Creates and automatically disposes a ScrollController. -
useStreamController<
T> ({void onListen()?, void onPause()?, void onResume()?, FutureOr< void> onCancel()?, bool sync = false}) → StreamController<T> -
Available on BuildContext, provided by the HooksContextExtension extension
Creates and automatically disposes a StreamController. -
useStreamControllerBroadcast<
T> ({void onListen()?, void onCancel()?, bool sync = false}) → StreamController< T> -
Available on BuildContext, provided by the HooksContextExtension extension
Creates and automatically disposes a StreamController.broadcast. -
useTabController(
{int initialIndex = 0, Duration? animationDuration, required int length, TickerProvider? vsync}) → TabController -
Available on BuildContext, provided by the HooksContextExtension extension
Creates and automatically disposes a TabController. -
useTextEditingController(
{String? text}) → TextEditingController -
Available on BuildContext, provided by the HooksContextExtension extension
Creates and automatically disposes a TextEditingController. -
useTickerProvider(
) → TickerProvider -
Available on BuildContext, provided by the HooksContextExtension extension
Creates and automatically disposes a TickerProvider. -
useVsync(
) → TickerProvider -
Available on BuildContext, provided by the HooksContextExtension extension
This is an alias for useTickerProvider. -
watch(
Listenable listener) → void -
Available on BuildContext, provided by the HooksContextExtension extension
Rebuilds this widget wheneverlistenernotifies. Automatically removes the listener when the widget is disposed.