This widget visualises a tree structure, where a node can be any widget.
https://flutter_simple_treeview.surge.sh/
TreeView(nodes: [
TreeNode(content: Text("root1")),
TreeNode(
content: Text("root2"),
children: [
TreeNode(content: Text("child21")),
TreeNode(content: Text("child22")),
TreeNode(
content: Text("root23"),
children: [
TreeNode(content: Text("child231")),
],
),
],
),
]),
custom_flutter_treeview:
git:
url: https://github.com/wldevproject/custom_flutter_treeview.git
ref: main # branch name
final TreeController treeController = TreeController(allNodesExpanded: false);
Widget buildTree(controller, treeController) {
try {
return Obx(() {
controller.isExpandedNetwork == true
? treeController.expandAll()
: treeController.collapseAll();
return TreeView(
nodes: toTreeNodes(controller.detailUser.value.downlines),
treeController: treeController,
);
});
} on FormatException catch (e) {
return Text(e.message);
}
}
..
nodes: toTreeNodes(controller.detailUser.value.downlines), -> list generate
..