expandAll method
void
expandAll()
Expand every node in the tree.
Child controllers are created lazily when a parent expands, so the tree is walked top-down: only after a parent is expanded do its children get controllers. Nodes are located by identity (NodeController.controllerOfItem) rather than by index, so we never read the per-node index cache while the tree is being mutated. The cache is reset once at the end so the next rebuild recomputes every index from a clean state.
Implementation
void expandAll() {
void expand(List<NodeData> nodes) {
for (final NodeData node in nodes) {
if (node.children.isEmpty) continue;
NodeController? controller = _rootController!.controllerOfItem(node);
if (controller == null) continue;
if (!controller.treeNode.expanded) {
expandItem(controller.treeNode);
}
expand(node.children);
}
}
expand(data!.cast<NodeData>());
_resetAllCaches(_rootController!);
notifyListeners();
}