-
-
Notifications
You must be signed in to change notification settings - Fork 465
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
Lazy expansion of TreeView nodes #135
Comments
I have thought of only populating nodes when it's opened. That was the first implementation, but then I faced an issue: when I select an item, then close a parent node, the selected node is messed and its state is not kept. I don't see a reason to add nodes only when it's opened. Could you explain more? |
In the scenario above, I'm using it for a registry editor. There are hundreds of thousands of nodes in total, and so iterating them all in advance is not viable for performance reasons. This is quite a fairly common scenario for tree view controls, since they're often used as a control for very deep data sources (another example would be the folder structure of the C:\ drive). Other TreeView controls handle this with the approach above or with a command. For example: |
Firstly, this package is fantastic. What an incredible piece of work. So grateful for your work.
Scenario
I have a
TreeView
where it's computationally expensive to calculate the nodes. So what I want is a callback that I can use to lazily populate a node when it's opened. I've solved this temporarily by forking your code and adding anonExpanded
callback. I've also added a non-visualPlaceholderTreeViewItem
that ensures the node is expandable, and when the callback is fired, I check whether the child is aPlaceholderTreeViewItem
. If so, I clear the children and populate at that point.The solution I have is workable, but you may well have a better one.
https://github.com/timsneath/regedit/blob/main/lib/custom_tree_view_item.dart
Example usage:
https://github.com/timsneath/regedit/blob/main/lib/registry_tree_view.dart
The text was updated successfully, but these errors were encountered: