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:
- StatefulComponentInstance is created.
- createState is called once to produce the associated state.
- ComponentState.initState runs before the first ComponentState.build.
- State changes trigger ComponentState.setState, causing a rebuild.
See also:
- ComponentState — manages the mutable state for a
StatefulComponent
. - StatefulComponentInstance — runtime instance of a
StatefulComponent
.
Constructors
- StatefulComponent.new()
-
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