I placed the TreeView on the second page of the PageView, the first time it entered normal, the second time there were duplicate items, or the expansion status was inconsistent.
Hi @bughoho, it seems that the TreeView is getting rebuilt when you change the page, which is causing the inconsistent behaviour. Try these steps to solve this issue:
Move the Tree state to the parent widget, so that the Tree instance does not change on page switching
Assign a PageStorageKey(refer to this medium article) to maintain the state of the PageView.
Assign a key to the TreeView to maintain its state, avoid rebuilds.
https://github.com/user-attachments/assets/27fdc233-2e44-444c-be97-ea7e36cfdb10
I placed the TreeView on the second page of the PageView, the first time it entered normal, the second time there were duplicate items, or the expansion status was inconsistent.