-
-
Notifications
You must be signed in to change notification settings - Fork 474
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
Solution for NavigationView to keep-alive tabs? #649
Comments
You can use |
@bdlukaa Thanks for the suggestion - I have looked deeply into paneBodyBuilder but I cannot figure out how this can help me. The IndexedStack implementation does not work here since the body widget is still passed by the NavigationPane and it does not provide the entire list. I even tried to ignore the provided body and use the index manually. but this also does not work since the build function is called each time the tab switches causing the entire stack to rebuild.
A code example for how panBodyBuilder could be used for this purpose would be greatly appreciated! I know a few others are also struggling to preserve the state of these tabs as well. |
@bdlukaa I have created a basic example using the template counter app to better show my issue. You can see (below) I am using AutomaticKeepAliveClientMixin (as mentioned in #604 and #607) but still the state is not being preserved. Based on your suggestion above - could you provide an example of how to modify this template app (maybe using paneBodyBuilder) such that the counter state can be saved whilst switching tabs? package version - fluent_ui: ^4.1.3
|
Hi, I am facing the same problem as reported by @b34st80y. The body state is not preserved when changing index, even using AutomaticKeepAliveClientMixin as shown in the example above. I am using -> fluent_ui: ^4.1.3 Please, can you provide a working example? EDIT: |
Hey! This is a common problem, and not only happens with Altough, by using |
Thank you! I was able to produce a workable solution using your second example. However I wanted to leave this comment to express some issues that I have still been having with this implementation in comparison to my old implementation with IndexedStack.
|
¹ This is expected. Only the state is stored - and heavy computation shouldn't be done inside the paneBodyBuilder: (body) {
return IndexedStack(
children: [
...,
],
);
}, |
In previous versions of fluent_ui, I was able to solve this using an IndexedStack in the NavigationView.content (this solution has been mentioned in a few other issues before muizidn@99f7f0c ) - however with the new breaking changes to NavigationView, this solution can not be implemented due to new PaneItem.body requirement.
I have looked at #607, but I am on the latest version (4.1.2) and with the new NavigationPane implementation my state is still being reset.
Is there a new recommended way to achieve this same behavior with the new NavigationView? Ideally I would like to use all of the nice features of the NavigationPane while still allowing the body(s) to stay-alive similar to an IndexedStack implementation.
The text was updated successfully, but these errors were encountered: