-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
node.add() method causes break in linking tree lines: File explorer example #43
Comments
I have also encountered this problem, may I ask if the problem has been solved |
I solved it by cloing the repo and adding void fixLastChild() {
for (var i = 0; i < childrenAsList.length; i++) {
if (childrenAsList[i] is TreeNode) {
(childrenAsList[i] as TreeNode).isLastChild = i == childrenAsList.length - 1;
}
}
} to listenable_node.dart and altering all the Then in return CustomPaint(
foregroundPainter: _IndentationPainter(
indentation: indentation,
node: node,
isLastChild: node.isLastChild,
minLevelToIndent: minLevelToIndent,
),
child: content,
); And alter it's @override
bool shouldRepaint(_IndentationPainter oldDelegate) {
return indentation != oldDelegate.indentation || node != oldDelegate.node || isLastChild != oldDelegate.isLastChild;
} Do not that it is O(n) for every operation so for large trees may be inadequate. It works for my specific usecase. |
I'm not sure if this error originated from me, but seeing this error here made me start thinking that it was caused by the package. My solution was different. I created the following special methods. It's easier than the method above and I think it will work for everyone facing this problem. It worked for me. Future<void> insertNodeBelow(IndexedTreeNode<dynamic> referenceNode,
IndexedTreeNode<dynamic> newNode) async {
if (referenceNode.isLastChild) {
referenceNode.isLastChild = false;
newNode.isLastChild = true;
}
referenceNode.parent?.insertAfter(referenceNode, newNode);
//my code
} and... Future<void> addNode(
IndexedTreeNode<dynamic> parent, IndexedTreeNode<dynamic> newNode) async {
for (final child in parent.children) {
if (child is IndexedTreeNode<dynamic>) {
child.isLastChild = false;
}
}
newNode.isLastChild = true;
parent.add(newNode);
//my code
} This is it. I hope the package owner does something to fix these bugs. |
… to update the indents on tree item update
I am adding nodes directly to a parent using method: node.add(). Items are added but the lines showing node link appears to break for the newly added node. See code and image below:
![node-break-screenshot](https://private-user-images.githubusercontent.com/37203863/313326735-b31450e7-eb11-4316-a0d2-2ee986ff638a.PNG?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQ4MDQzMzksIm5iZiI6MTcyNDgwNDAzOSwicGF0aCI6Ii8zNzIwMzg2My8zMTMzMjY3MzUtYjMxNDUwZTctZWIxMS00MzE2LWEwZDItMmVlOTg2ZmY2MzhhLlBORz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MjglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODI4VDAwMTM1OVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWZlNGRjMmUzNGRhMGIwZmY1OTAyMzU5MWNlNWU3NDQ0NWJhMzRiMDRkM2EwMTE0MWUzYjQ0YzRkNjZlMTU3NGUmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.xdTvrOV4dp0ekx8OQVSTYI54ZQknbiZdjZKhlEk9tVg)
node.add(SeasonNode());
The text was updated successfully, but these errors were encountered: