HookWidget class abstract
A StatelessWidget whose build calls hooks.
A counter whose count is the state of a useState:
final class Counter extends HookWidget {
const Counter({super.key});
@override
Widget build(BuildContext context) {
final count = useState(0);
return KeyBindings({
'up': () => count.value++,
}, child: Text('Count: ${count.value}'));
}
}
See also:
- HookBuilder, the same written in place.
- StatefulHookWidget, for a State whose build calls hooks.
- Inheritance
-
- Object
- Widget
- StatelessWidget
- HookWidget
- Implementers
Constructors
- HookWidget({Key? key})
-
Lets a subclass be constant.
const
Properties
Methods
-
build(
BuildContext context) → Widget -
Describes this part of the interface; called when the widget is placed
in the tree, whenever its parent gives it a new widget, and when its
element is marked dirty.
inherited
-
createElement(
) → StatelessElement -
Inflates this widget into a new element for the tree.
override
-
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Adds what describes this widget in its element's description
(Element.describe) to
properties, those not worth showing (a default) left out; an override calls this first. A render object widget adds only what its render object does not show. Only Element.describe calls it: a frame never does.inherited -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited