TreeController constructor

TreeController({
  1. required List<TreeNode<Object?>> initialNodes,
  2. void onAttached(
    1. TreeNode<Object?> node,
    2. TreeNode<Object?>? parent
    )?,
  3. void onRemoved(
    1. TreeNode<Object?> node,
    2. TreeNode<Object?>? parent
    )?,
  4. void onChanged()?,
  5. void onMoved(
    1. TreeNode<Object?> node,
    2. int position,
    3. TreeNode<Object?>? oldParent,
    4. TreeNode<Object?>? newParent,
    )?,
})

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);
}