TreeController constructor
TreeController({})
Wraps a Tree and exposes methods to control or read certain aspects of this tree.
Implementation
TreeController({
///The tree this controller will contain at its construction
required List<TreeNode> initialNodes,
///A callback to preform sideeffects when a child is added to a node
void Function(TreeNode node, TreeNode? parent)? onAttached,
///A callback to preform sideeffects when a child is removed from a node
void Function(TreeNode node, TreeNode? parent)? onRemoved,
///A callback to perform sideeffect when tree configuration changes.
///This will be called only once if the tree changes, instead of being called for every node that changes.
void Function()? onChanged,
///A callback to preform sideeffection when a node is moved to another location in the tree
///the position parameter is the position the node has in the array of siblings.
///
///equal to node.index
void Function(
TreeNode node,
int position,
TreeNode? oldParent,
TreeNode? newParent,
)?
onMoved,
}) : _onAttached = onAttached,
_onRemoved = onRemoved,
_onMoved = onMoved,
_onChanged = onChanged,
rootNodes = initialNodes {
_initToDict(null, rootNodes, 0);
}