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

Save state of the widgets in the NavigationPane #856

Closed
EchoEllet opened this issue Jun 7, 2023 · 3 comments
Closed

Save state of the widgets in the NavigationPane #856

EchoEllet opened this issue Jun 7, 2023 · 3 comments

Comments

@EchoEllet
Copy link
Contributor

EchoEllet commented Jun 7, 2023

Is your feature request related to a problem? Please describe.
The NavigationPane doesn't save the state of the widget when navigating between different items in the navigation menu and we
have to manually split the state from the UI and use state management packages like provider or flutter_riverpod etc...
and AutomaticKeepAliveClientMixin doesn't work because of the way that NavigationPane works
at least make it works like the way it is in Material UI so we can fix that or make it automatic like Cupertino UI

Describe the solution you'd like
I already did,

Describe alternatives you've considered
Material UI and Cupertino

Additional context
I don't have anything else to say

@thitlwincoder
Copy link
Contributor

I try this. It work for me.

paneBodyBuilder: (item, body) {
  return body!;
},

@bdlukaa
Copy link
Owner

bdlukaa commented Jun 11, 2023

Assigning a key to the item may also work

@bdlukaa
Copy link
Owner

bdlukaa commented Aug 12, 2023

You can add an AutomaticKeepAliveMixin mixin to your body widgets. You can also make use of page storage to save the state.

AutomaticKeepAliveClientMixin doesn't work because of the way that NavigationPane works

Recently, NavigationView now uses PageView under the hood to render the body widgets. This enables the usage of AutomaticKeepAliveClientMixin

If you make use of go_router, you can use StatefulShellRoute.

Related #910

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

3 participants