parentProvider property

ParentProvider<T> parentProvider
latefinal

A getter callback that should return the direct parent of the tree node that is given to it or null if given a root node.

This callback must return null when either a root node or an orphan node is given to it. Otherwise this could lead to infinite loops while walking up the ancestors of a tree node.

When not defined, this will be set to a callback that always returns null.

Some methods like expandAncestors and checkNodeHasAncestor depend on this callback and will throw an AssertionError in debug mode when not defined.

Avoid doing heavy computations in this callback as it may be called a lot while walking the ancestors of a tree node.

Example:

class Node {
  Node? parent;
}

TreeController<Node> treeController = TreeController<Node>(
  ...
  parentProvider: (Node node) => node.parent,
);

Implementation

late final ParentProvider<T> parentProvider;