createNodeController method
Create controllers for each child node
Implementation
List<NodeController> createNodeController(
NodeController parentController, List<int> indexes) {
List<NodeController> children =
parentController.childControllers.map((e) => e).toList();
List<NodeController> newChildren = [];
indexes.forEach((element) {});
for (int i in indexes) {
NodeController? controller;
NodeController? oldController;
var lazyItem = TreeNodeItem(
parent: parentController.treeNode.item, controller: this, index: i);
parentController.childControllers.forEach((controller) {
if (controller.treeNode.item == lazyItem.item) {
oldController = controller;
}
});
if (oldController != null) {
controller = oldController;
} else {
controller = NodeController(
parent: parentController,
nodeItem: lazyItem,
expandCallback: (NodeData? item) {
bool result = false;
children.forEach((controller) {
if (controller.treeNode.item == item) {
result = true;
}
});
return result;
});
}
newChildren.add(controller!);
}
return newChildren;
}