StatefulComponentInstance class
Runtime instance of a StatefulComponent.
A StatefulComponentInstance
owns and manages the ComponentState
for its StatefulComponent, builds its child components, and
coordinates their layout and rendering.
Responsibilities:
- Initialize and hold a single ComponentState instance.
- Build and cache child ComponentInstances.
- Rebuild children when requested by the state.
- Perform layout measurement via fitWidth, fitHeight, and measure.
- Render children to a CanvasBuffer.
Lifecycle:
- Created from a StatefulComponent.
- Lazily creates the state when state is first accessed.
- rebuild replaces the child component tree using ComponentState.build.
See also:
- StatefulComponent — defines the component’s configuration.
- ComponentState — holds mutable state and triggers rebuilds.
- ParentComponentInstance — base class for components with children.
- Inheritance
-
- Object
- ComponentInstance
- ParentComponentInstance
- StatefulComponentInstance
Constructors
- StatefulComponentInstance.new(StatefulComponent component)
-
Creates a new StatefulComponentInstance for the given
component
.
Properties
- bounds ↔ Rect
-
The current layout bounds for this component instance.
getter/setter pairinherited
- childGap → int
-
Vertical spacing between children when laid out.
final
-
children
← List<
Component> -
Replaces the list of child components without building them.
no getter
-
childrenInstance
→ List<
ComponentInstance> -
Returns the list of runtime child instances.
no setteroverride
- component → StatefulComponent
-
The configuration for this component instance.
final
- direction → Axis
-
The primary axis along which children are laid out.
Defaults to vertical stacking.
no setterinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- padding → EdgeInsets
-
The padding inside the component’s allocated space.
finalinherited
- position → Position
-
The position of this component relative to its parent or container.
finalinherited
- renderManager ↔ RenderManager?
-
The render manager that may schedule renders for this instance.
getter/setter pair
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
state
→ ComponentState<
StatefulComponent> -
Lazily initializes and returns this component’s state.
no setter
Methods
-
fitHeight(
) → int -
Calculates the total height required to fit all children,
including the childGap between them.
override
-
fitWidth(
) → int -
Calculates the maximum width required to fit all children.
override
-
measure(
Size maxSize) → Size -
Measures the size this component would take given
maxSize
.override -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
rebuild(
) → void - Rebuilds the child component list from the current state.
-
render(
CanvasBuffer buffer, Rect bounds) → void -
Renders all children into the given
buffer
withinbounds
.override -
shouldRenderChild(
ComponentInstance child) → bool -
Determines whether a given
child
should be rendered. Defaults tofalse
, meaning the decision is left to layout/rendering code.inherited -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited