AppInstance class Core
The root ComponentInstance for a Pixel Prompt application.
An AppInstance
is a specialized ParentComponentInstance
that owns the top-level component tree and coordinates rendering.
It is a singleton during the app's lifetime, accessible via AppInstance.instance.
Responsibilities:
- Hold the root component (App) and its child instances.
- Perform layout measurement for the entire application.
- Render components to the terminal buffer.
- Schedule and manage rebuilds.
Lifecycle:
- Created once at app startup.
- Rebuilds occur when requestRebuild is called.
- Rendering happens through render, which delegates to the layout engine.
See also:
- App — the root component type used to define the application's UI.
- ComponentInstance — the base interface implemented by all component instances.
- Inheritance
-
- Object
- ComponentInstance
- ParentComponentInstance
- AppInstance
Constructors
- AppInstance.new(App component)
- Creates an application instance for the given root App component.
Properties
- bounds ↔ Rect
-
The current layout bounds for this component instance.
getter/setter pairinherited
-
childrenInstance
→ List<
ComponentInstance> -
Returns the current set of root-level children.
no setteroverride
- component → App
-
The root App component.
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
-
initialChildren
↔ List<
ComponentInstance> -
The initially created children, preserved for reference.
getter/setter pair
- 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
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- shouldRebuild ↔ bool
-
Whether the app should perform a rebuild in the next cycle.
getter/setter pair
Methods
-
fitHeight(
) → int -
Returns the height this component should occupy
based on its content or layout rules.
override
-
fitWidth(
) → int -
Returns the width this component should occupy
based on its content or layout rules.
override
-
measure(
Size maxSize) → Size -
Measures the total size required to render all children.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
render(
CanvasBuffer buffer, Rect bounds) → void -
Renders the app by delegating to the layout engine and drawing
each positioned child to the CanvasBuffer.
override
-
requestRebuild(
) → void - Marks the app as needing a rebuild.
-
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
Static Properties
- instance ↔ AppInstance
-
Global singleton instance of the app.
getter/setter pair