0

This is the structure of some of my go_router routes,

ShellRoute(routes: [  

Settingspage ( routes: [ settings page sub routes ] ),
Homepage ( routes: [ userprofilepage -> (== GoRoute != shellRoute)] ), 

],
)

settingspage and homepage are sub routes of shellRoute, so they share an appbar and a bottom navigation bar and highlights homepage icon or settingspage icon when the respective item is pressed on the bottom navigation bar.

user profile page on the other hand is using GoRoute and is NOT using shell route's navigator so it doesn't share appbar or bottomNavBar uses it own navigator, and on back press it pops back to Homepage.

You go to user profile page from a button press in drawer.

The problem is when you go to user_profile_page from the drawer with settings page selected on the bottom navigation bar and press back on user_profile_page you go back to homepage as user_profile_page is a sub route of homepage, BUT THE SETTINGS ICON STAYS HIGHLIGHTED. I don't want this as the user will be on homepage now.

Some of the things I tried (but I think there should be a much better, proper way of doing this),

  1. Not use shell route. on homepage and settings page and each one gets their own copy of bottomNavBar, but then bottom nav bar will be jumpy and code with be duplicated.

  2. Send data to user_profile_page from homepage or settingspage. and on back button press, check received data to see from which page did we come from and which page should we go back to.

0 Answers0