Skip to content
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

Dynamic change of root #23

Open
garth-waters opened this issue Aug 31, 2023 · 2 comments
Open

Dynamic change of root #23

garth-waters opened this issue Aug 31, 2023 · 2 comments

Comments

@garth-waters
Copy link

Hi,

Thanks very much for this package.
I seem to have an issue when I change the root node and rebuild the treeview widget.
The treeview builds the same but when the build method is called it seems to remember the old root nodes. The build method is called with nodes that no longer exist in the new root node.
As an example if I create a root node with 3 nodes the build method is correctly called 3 times.
Then if I change the root node to just 1 node and rebuild then the builder is called 4 times.
This is the root node output - IndexedNode{children: [IndexedNode{children: [], key: 1, parent: IndexedNode{children: [...], key: /, parent: null}}], key: /, parent: null}

I am using the GetIt mixin with a stateless widget to create the TreeView.

Many Thanks
Garth

@jawwad-hassan89
Copy link
Contributor

HI. Garth,
Whenever the tree is updated, using any state management tool like GetIt, the didUpdateTree. All the update in the tree, including node add, insert, remove and modify are calculated, and the changes are applied to the old tree.
Simply replacing the tree root will not work, library uses the AnimatedListView which keeps are permanent reference to the lists, and all the changes need to be applied the list being reference by AnimatedListView.

I would advise that first make sure that your tree changes are being properly applied by looking into whether the didUpdateTree method is being called, and the diffs are being properly calculated.
After that, please debug whether your State Management tool, is actually updating the widget tree or not when you are modifying the three

@jawwad-hassan89
Copy link
Contributor

for reference you can check out the nodes_data_update_sample.dart

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants