State<T extends StatefulWidget> class abstract

The logic and internal state for a StatefulWidget.

State is information that (1) can be read synchronously when the widget is built and (2) might change during the lifetime of the widget. It is the responsibility of the widget implementer to ensure that the State is promptly notified when such state changes, using State.setState.

State objects are created by the framework by calling the StatefulWidget.createState method when inflating a StatefulWidget to insert it into the tree. Because a given StatefulWidget instance can be inflated multiple times (e.g., the widget is incorporated into the tree in multiple places at once), there might be more than one State object associated with a given StatefulWidget instance. Similarly, if a StatefulWidget is removed from the tree and later inserted in to the tree again, the framework will call StatefulWidget.createState again to create a fresh State object, simplifying the lifecycle of State objects.

State objects have the following lifecycle:

See also:

Mixed-in types
Implementers
Annotations

Constructors

State()

Properties

context BuildContext
The location in the tree where this widget builds.
no setter
hashCode int
The hash code for this object.
no setterinherited
mounted bool
Whether this State object is currently in a tree.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
widget → T
The current configuration.
no setter

Methods

activate() → void
Called when this object is reinserted into the tree after having been removed via deactivate.
build(BuildContext context) Widget
Describes the part of the user interface represented by this widget.
deactivate() → void
Called when this object is removed from the tree.
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
override
didChangeDependencies() → void
Called when a dependency of this State object changes.
didUpdateWidget(covariant T oldWidget) → void
Called whenever the widget configuration changes.
dispose() → void
Called when this object is removed from the tree permanently.
initState() → void
Called when this object is inserted into the tree.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
reassemble() → void
Called whenever the application is reassembled during debugging, for example during hot reload.
setState(VoidCallback fn) → void
Notify the framework that the internal state of this object has changed.
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
inherited
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) String
A string representation of this object.
inherited
toStringShort() String
A brief description of this object, usually just the runtimeType and the hashCode.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited