flatten<T> static method

List<FlatNode<T>> flatten<T>({
  1. required List<Node<T>> nodes,
  2. required Set<String>? expandedNodeIds,
  3. int depth = 0,
  4. bool isRoot = true,
  5. int ancestorIsLastMask = 0,
})

Flattens a tree of nodes into a list of FlatNodes, only including children of expanded nodes.

This produces the visible node list for virtualized rendering.

Implementation

static List<FlatNode<T>> flatten<T>({
  required List<Node<T>> nodes,
  required Set<String>? expandedNodeIds,
  int depth = 0,
  bool isRoot = true,
  int ancestorIsLastMask = 0,
}) {
  final result = <FlatNode<T>>[];
  _flattenInto<T>(
    result: result,
    nodes: nodes,
    expandedNodeIds: expandedNodeIds,
    depth: depth,
    isRoot: isRoot,
    ancestorIsLastMask: ancestorIsLastMask,
  );
  return result;
}