TreeNode<T> class

The schema for a single node, generic over its value type T. This is the customisation surface: a host composes a List<TreeNode<T>> (each with its own children) to define the whole tree. Immutable — structural edits in the controller produce new node objects via copyWith, which makes undo/redo a cheap reference swap.

Annotations

Constructors

TreeNode({required TreeNodeId id, required String label, List<TreeNode<T>> children = const [], T? value, IconData? icon, String? badge, bool? folder, bool selectable = true, Map<String, Object?> data = const {}})
const

Properties

badge String?
Optional trailing badge text (a count, a status, a shortcut…).
final
children List<TreeNode<T>>
Child nodes. Empty for a leaf (or for an empty folder — see folder).
final
data Map<String, Object?>
Arbitrary, loosely-typed metadata travelling with the node. Prefer value for the primary payload; use this for incidental flags.
final
folder bool?
Whether this node can hold children — i.e. renders a disclosure twisty and accepts "add child". When null it's inferred: a node is a folder iff it currently has children. Set true for an empty folder, false to force a leaf even though children were supplied.
final
hasChildren bool
Has at least one child right now.
no setter
hashCode int
The hash code for this object.
no setteroverride
icon IconData?
Optional leading icon override. When null the view picks a sensible default (folder-open / folder / leaf dot) from the node's role.
final
id TreeNodeId
Unique, stable id across the whole tree.
final
isFolder bool
Does this node act as a folder (expandable / can receive children)?
no setter
label TreeNodeId
Display label (also what inline-rename and search match against).
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
selectable bool
When false the row can't be selected (still expandable / shown).
final
value → T?
Strongly-typed host payload travelling with the node. null for nodes that carry no domain object (e.g. structural group headers).
final

Methods

copyWith({TreeNodeId? id, String? label, List<TreeNode<T>>? children, Object? value = _sentinel, IconData? icon, Object? badge = _sentinel, Object? folder = _sentinel, bool? selectable, Map<String, Object?>? data}) TreeNode<T>
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() TreeNodeId
A string representation of this object.
inherited

Operators

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