getChildByIndexPath method

Node? getChildByIndexPath(
  1. Iterable<int> indexPath
)

Resolves an indexPath (as produced by getIndexPath) to a descendant node, or null if any segment is out of range.

Implementation

Node? getChildByIndexPath(Iterable<int> indexPath) {
  Node? current = this;
  for (var index in indexPath) {
    if (index < 0 || index >= current!.children.length) {
      return null;
    }
    current = current.children[index];
  }
  return current;
}