I have an app with two pages , the first one has a button to navigate to the second and then choose a list of places, on save the second page pops and return the first page where the chosen places are shown in chips , but If a return to the second page to edit my choices the state is now re-builded and my list is gone How to persist the list state in the second page?
Asked
Active
Viewed 933 times
2

David De Jesus
- 101
- 9
-
State won't dispose if _maintainState_ parameter of PageRoute is true (and it is true by default). Sounds like you have some business logic inside build function and when you pop back your widget rebuilds. Show us the code, please. – Igor Kharakhordin Nov 09 '19 at 14:16
-
1@IgorKharakhordin he states that it's on returning to the second page that it rebuilds. This is because you need to store the state of the selected choice somewhere above the Navigator. An InheritedWidget/Provider/ScopedModel would be a sufficient solution to store the state like you're looking to do. – Adrian Murray Nov 09 '19 at 19:14
-
https://medium.com/@lucassaltoncardinali/keeping-state-with-the-bottom-navigation-bar-in-flutter-69e4168878e1 check it out – griffins Nov 10 '19 at 14:25