TreeModel<T> class final TUI

Shared state and interaction policy for hierarchical tree views.

The model owns stable expansion, selection, visible-row projection, and viewport offset. String-based TEA applications can render view directly; widget applications can render rows and control the same model.

Inheritance

Constructors

TreeModel({required Iterable<TreeItem<T>> items, int height = 0, int width = 0, int indentSize = 2, int mouseWheelDelta = 3, String? initialSelectedId, TreeKeyMap? keyMap, TreeStyles? styles})

Properties

cursor → int
Selected projected row index.
no setter
hashCode → int
The hash code for this object.
no setterinherited
height ↔ int
Number of rows in the viewport. Zero shows all rows.
getter/setter pair
horizontalOffset → int
Number of cells hidden from the left edge by horizontal panning.
no setter
indentSize ↔ int
Number of cells in each branch indentation.
getter/setter pair
items → List<TreeItem<T>>
Root tree items.
no setter
keyMap → TreeKeyMap
Keyboard bindings.
final
maxHorizontalOffset → int
Maximum horizontal offset for the current rows and width.
no setter
maxOffset → int
Maximum viewport offset.
no setter
mouseWheelDelta ↔ int
Rows scrolled per mouse-wheel event.
getter/setter pair
offset → int
Current viewport offset.
no setter
rows → List<TreeRow<T>>
Complete flattened projection after applying expansion state.
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
selectedItem → TreeItem<T>?
Currently selected item.
no setter
styles → TreeStyles
String renderer styles.
final
visibleRows → List<TreeRow<T>>
Rows currently inside the model viewport.
no setter
width ↔ int
Number of cells in the horizontal viewport. Zero leaves panning unbound.
getter/setter pair

Methods

collapse(String id) → bool
Collapses one branch.
collapseAll() → void
Collapses every branch.
expand(String id) → bool
Expands one branch.
expandAll() → void
Expands every branch.
init() → Cmd?
Returns an optional command to execute on program startup.
override
isExpanded(String id) → bool
Whether id is currently expanded.
moveBy(int delta) → bool
Moves selection by delta visible selectable rows.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
panBy(int delta) → bool
Pans the viewport horizontally by delta cells.
replaceItems(Iterable<TreeItem<T>> items) → void
Replaces tree content while preserving state for IDs that remain.
scrollBy(int delta) → bool
Scrolls the viewport by delta rows without changing selection.
select(String id) → bool
Selects the visible item with id.
setHorizontalOffset(int offset) → bool
Sets the horizontal viewport offset.
setOffset(int offset) → bool
Sets an absolute viewport offset.
toggle(String id) → bool
Toggles a branch. Returns whether expansion state changed.
toString() → String
A string representation of this object.
inherited
update(Msg msg) → (TreeModel<T>, Cmd?)
Updates the component state in response to a message.
override
view() → String
Renders the current model state for display.
override

Operators

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