TreeController<T> class

Inheritance

Constructors

TreeController({required List<TreeNode<T>> roots, Set<TreeNodeId>? expanded, Set<TreeNodeId>? checked, TreeNodeId? selected, Set<TreeNodeId>? selection, TreeSelectionMode selectionMode = TreeSelectionMode.single, int historyLimit = 200})

Properties

canRedo bool
no setter
canUndo bool
no setter
checkedLeafIds Set<TreeNodeId>
Ids of every checked leaf (the meaningful selection for a host).
no setter
editing TreeNodeId?
no setter
filtering bool
no setter
focused TreeNodeId?
no setter
hashCode int
The hash code for this object.
no setterinherited
hasListeners bool
Whether any listeners are currently registered.
no setterinherited
historyLimit int
final
matchCount int
How many nodes currently match the search query (0 when not filtering).
no setter
nodeCount int
no setter
query String
no setter
roots List<TreeNode<T>>
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
selected TreeNodeId?
no setter
selectedNodes List<TreeNode<T>>
The selected nodes' values, in visible (top-to-bottom) order — for group actions (delete, move, export…).
no setter
selection Set<TreeNodeId>
Every selected node id (click/keyboard selection). In single mode this is at most one; in multi mode any number. Empty when nothing is selected.
no setter
selectionCount int
no setter
selectionMode TreeSelectionMode
What clicks / keyboard selection do. Mutable so a host can flip single ↔ multi at runtime (e.g. entering a “select” mode).
getter/setter pair

Methods

activateFocused() TreeNode<T>?
Toggle / activate the focused row: folders expand, leaves select. Returns the activated leaf node (for the host to open), or null.
addChild(TreeNodeId parentId, {String label = 'New item', bool folder = false, T? value}) TreeNodeId
Append a new child under parentId, expand it, select & begin renaming the new node. Returns the new node's id.
addListener(VoidCallback listener) → void
Register a closure to be called when the object changes.
inherited
addSibling(TreeNodeId id, {String label = 'New item', T? value}) TreeNodeId
Insert a sibling immediately after id (or append at root if id has no parent and isn't found nested). Returns the new node's id.
beginEdit(TreeNodeId id) → void
cancelEdit() → void
checkState(TreeNode<T> n) TreeCheck
clearSelection() → void
Clear the click/keyboard selection (leaves checkboxes alone).
collapse(TreeNodeId id) → void
collapseAll() → void
commitEdit(TreeNodeId id, String label) → void
Commit an inline rename. Empty / unchanged labels just close the editor.
dispose() → void
Discards any resources used by the object.
inherited
duplicate(TreeNodeId id) TreeNodeId?
Duplicate id (with a fresh id subtree) as the next sibling.
expand(TreeNodeId id) → void
expandAll() → void
focus(TreeNodeId id) → void
focusFirst() → void
focusInto() → void
→ key: expand a collapsed folder, else step into the first child.
focusLast() → void
focusOut() → void
← key: collapse an expanded folder, else step out to the parent.
isExpanded(TreeNodeId id) bool
isSelected(TreeNodeId id) bool
moveFocus(int delta) → void
Move the keyboard cursor by delta rows through the visible list.
node(TreeNodeId id) TreeNode<T>?
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notifyListeners() → void
Call all the registered listeners.
inherited
redo() → void
remove(TreeNodeId id) → void
Remove id and everything beneath it.
removeListener(VoidCallback listener) → void
Remove a previously registered closure from the list of closures that are notified when the object changes.
inherited
removeSelected() int
Remove every node in the current multi-selection (and their subtrees), as a single undoable step. Ancestors are dropped from the work-list so a parent + child selected together don't double-remove. Returns the count.
replaceRoots(List<TreeNode<T>> roots) → void
Replace the whole forest (resets history). For host-driven reloads.
revealNode(TreeNodeId id) → void
Expand only the node and its ancestors so a deep node is revealed.
select(TreeNodeId id) → void
selectAllVisible() → void
Select every selectable, currently-visible node (multi mode).
selectWith(TreeNodeId id, {bool toggle = false, bool range = false}) → void
Pointer/keyboard selection honouring modifier keys and selectionMode: • plain → select only id (resets the set) • toggle → Ctrl/⌘-click: add/remove id, keep the rest (multi only) • range → Shift-click: select the contiguous visible range from the anchor to id (multi only) Falls back to single behaviour when selectionMode isn't multi.
setChecked(Iterable<TreeNodeId> ids) → void
setQuery(String q) → void
toggle(TreeNodeId id) → void
toggleCheck(TreeNodeId id) → void
Toggle a node's check: cascades to every leaf beneath it (a lone leaf toggles itself). Pure state — not part of structural undo history.
toString() String
A string representation of this object.
inherited
undo() → void
valueOf(TreeNodeId id) → T?
The strongly-typed value behind id, or null.
visibleRows() List<TreeRow<T>>
The visible rows in render order. While searching, only matches and their ancestors are shown, and ancestor folders are force-expanded so the hits are revealed.

Operators

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

Static Methods

of<T>(BuildContext context) TreeController<T>?