StatefulHookWidget class abstract

A StatefulWidget whose state's build calls hooks, besides keeping what a State keeps. Its hooks are deactivated before the state and disposed before it, activated after it.

A state that keeps a field of its own and calls a hook in its build:

final class Search extends StatefulHookWidget {
  const Search({super.key});

  @override
  State<Search> createState() => _SearchState();
}

final class _SearchState extends State<Search> {
  var _searches = 0;

  @override
  Widget build(BuildContext context) {
    final controller = useTextEditingController();
    return TextField(
      controller: controller,
      onSubmitted: (_) => setState(() => _searches++),
    );
  }
}
Inheritance

Constructors

StatefulHookWidget({Key? key})
Lets a subclass be constant.
const

Properties

hashCode → int
The hash code for this object.
no setterinherited
key → Key?
Tells this widget apart from its siblings; see Key.
finalinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

createElement() → StatefulElement
Inflates this widget into a new element for the tree.
override
createState() → State<StatefulWidget>
Creates the state of a new element; it lives as long as the element.
inherited
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