TreeController class

A controller that manages a tree consisting of many treenodes. Exposes methods to: get, attach, move, delete or modify nodes.

Inheritance

Constructors

TreeController.new({required List<TreeNode<Object?>> initialNodes, void onAttached(TreeNode<Object?> node, TreeNode<Object?>? parent)?, void onRemoved(TreeNode<Object?> node, TreeNode<Object?>? parent)?, void onChanged()?, void onMoved(TreeNode<Object?> node, int position, TreeNode<Object?>? oldParent, TreeNode<Object?>? newParent)?})
Wraps a Tree and exposes methods to control or read certain aspects of this tree.

Properties

hashCode int
The hash code for this object.
no setterinherited
hasListeners bool
Whether any listeners are currently registered.
no setterinherited
rootCount int
The number of rootnodes in the tree.
no setter
rootNodes List<TreeNode<Object?>>
The rootnodes of this tree.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

addListener(VoidCallback listener) → void
Register a closure to be called when the object changes.
inherited
attachRoot(TreeNode<Object?> node, {bool notify = true}) → void
Add a node to the root of this tree
collapseAll({bool notify = true}) → void
Collapses all nodes in the tree.
dispose() → void
Discards any resources used by the object. After this is called, the object is not in a usable state and should be discarded (calls to addListener will throw after the object is disposed).
inherited
expandAll({bool notify = true}) → void
Expands all nodes in the tree.
getByIdentifier(Object identifier, {bool notify = true}) TreeNode<Object?>
Get a node registered in this controller by its identifier.
maybeGetByIdentifier(Object identifier) TreeNode<Object?>?
Get a node registered in this controller by its identifier. Returns null if no corresponding node is found.
move(TreeNode<Object?> node, int index, {TreeNode<Object?>? newParent, bool notify = true}) → void
Move a node to a new position in the tree, takes the following arguments:
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notifyListeners() → void
Call all the registered listeners.
inherited
remove(TreeNode<Object?> node, {bool notify = true}) → void
Remove a node from this tree
removeListener(VoidCallback listener) → void
Remove a previously registered closure from the list of closures that are notified when the object changes.
inherited
swap(TreeNode<Object?> node1, TreeNode<Object?> node2, {bool notify = true}) → void
Swap two nodes in the tree. This moves node1 to the position of node2 and node2 to the position of node1.
toString() String
A string representation of this object.
inherited
traverse(void action(TreeNode<Object?>)) → void
Traverses all the nodes attached to the tree. Calling back action on each node hit.

Operators

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