SignalHookWidget class abstract
A premium reactive widget that both supports Flutter Hooks and implicitly tracks and rebuilds on signal changes.
SignalHookWidget establishes a dynamic reactive context directly at the Flutter element layer.
Any signal accessed via .value inside the build method is implicitly tracked and
subscribed to. At the same time, you can call any hooks (like useFocusNode, useTextEditingController, etc.)
within build.
This provides the ultimate developer experience, combining the power of implicit, boilerplate-free signal tracking with the rich lifecycle management of Flutter Hooks.
Dual Reactivity Example
final globalCartCount = signal(0);
class MyDualWidget extends SignalHookWidget {
const MyDualWidget({super.key});
@override
Widget build(BuildContext context) {
// 1. Declare hooks seamlessly:
final controller = useTextEditingController();
final focusNode = useFocusNode();
final localCounter = useSignal(0);
// 2. Implicit tracking of external/global signals:
// No .watch(context) needed! Just accessing .value tracks it.
return Column(
children: [
TextField(controller: controller, focusNode: focusNode),
Text('Global Signal: ${globalCartCount.value}'),
Text('Local Signal: ${localCounter.value}'),
],
);
}
}
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatelessWidget
- SignalHookWidget
- Available extensions
Constructors
- SignalHookWidget({Key? key})
-
Constructor for SignalHookWidget.
const
Properties
Methods
-
build(
BuildContext context) → Widget -
Subclasses override this method to define their widget tree.
override
-
buildWidget(
BuildContext context) → Widget - Subclasses override this method instead of build to define their widget tree.
-
createElement(
) → StatelessElement -
Creates a StatelessElement to manage this widget's location in the tree.
override
-
debugDescribeChildren(
) → List< DiagnosticsNode> -
Returns a list of DiagnosticsNode objects describing this node's
children.
inherited
-
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Add additional properties associated with the node.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toDiagnosticsNode(
{String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode -
Returns a debug representation of the object that is used by debugging
tools and by DiagnosticsNode.toStringDeep.
inherited
-
toSignalWidget(
) → SignalWidget -
Available on StatelessWidget, provided by the StatelessWidgetConvertWidgetExtension extension
Converts this StatelessWidget to a SignalWidget. -
toString(
{DiagnosticLevel minLevel = DiagnosticLevel.info}) → String -
A string representation of this object.
inherited
-
toStringDeep(
{String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) → String -
Returns a string representation of this node and its descendants.
inherited
-
toStringShallow(
{String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String -
Returns a one-line detailed description of the object.
inherited
-
toStringShort(
) → String -
A short, textual description of this widget.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited