TreeRoot<T> class

A special tree node that serves as an invisible root container.

TreeRoot represents the invisible root of a tree structure that contains other tree nodes but doesn't appear in the visual tree. It's always considered expanded and never selected, serving purely as a container for organizing multiple top-level tree items.

This is useful when you need to group multiple tree items under a common parent without showing that parent in the tree view. All children of a TreeRoot appear at the top level of the tree.

TreeRoot maintains immutability like other tree nodes, but state update operations (expanded/selected) have no effect since these properties are fixed by design.

Example:

TreeRoot<String> root = TreeRoot(
  children: [
    TreeItem(data: 'First Section'),
    TreeItem(data: 'Second Section'),
    TreeItem(data: 'Third Section'),
  ],
);

// Root is always expanded and never selected
print(root.expanded); // true
print(root.selected); // false
Inheritance

Constructors

TreeRoot.new({required List<TreeNode<T>> children})
Creates a TreeRoot container with the specified children.

Properties

children List<TreeNode<T>>
List of child nodes contained in this root.
final
expanded bool
Always returns true since root containers are conceptually always expanded.
no setteroverride
hashCode int
The hash code for this object.
no setteroverride
leaf bool
Whether this node is a leaf (has no children).
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
selected bool
Always returns false since root containers cannot be selected.
no setteroverride

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
override
updateChildren(List<TreeNode<T>> children) TreeRoot<T>
Creates a new instance with updated children list.
override
updateState({bool? expanded, bool? selected}) TreeRoot<T>
Creates a new instance with updated expansion and/or selection state.
override

Operators

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