StatefulComponent class abstract Components Core State Management

A Component that has an associated mutable ComponentState.

A StatefulComponent allows encapsulating local state and rebuilding its widget tree when that state changes. The state is represented by a ComponentState subclass, which is created via createState.

The runtime representation is a StatefulComponentInstance, which holds the component’s state, builds its children, and coordinates rendering.

Lifecycle:

  1. StatefulComponentInstance is created.
  2. createState is called once to produce the associated state.
  3. ComponentState.initState runs before the first ComponentState.build.
  4. State changes trigger ComponentState.setState, causing a rebuild.

See also:

Inheritance

Constructors

StatefulComponent()
Creates a stateful component that can maintain mutable state.
const

Properties

hashCode → int
The hash code for this object.
no setterinherited
padding → EdgeInsets
The padding inside the component’s layout bounds.
finalinherited
position → Position?
The position of the component within its parent or layout.
finalinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

createInstance() → ComponentInstance
Creates a ComponentInstance that can be rendered.
override
createState() → ComponentState<StatefulComponent>
Creates the mutable state object associated with this component.
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