romanejaquez/home_automation_app

Routing detection issue

Opened this issue · 1 comments

Hello Dear
when i try click the button to navigate to new Page i use
GoRouter.of(Utils.tabNav.currentContext!).go('/rooms');
the function is work it navigate to the route it show the new destination page but the Icon on the BottomBar will not swap to new page it remain on the selected icon , please how to fix that ?

hey @rebazjabar so you're trying to perform the navigation away from the navigation bar (i.e. using GoRouter in another context). If you want to navigate to the Rooms Page while at the same time update the bottom bar icon so it changes, you must mark the item as selected in the bottom bar programmatically. I just updated the code and added a new method in the BottomBarViewModel:

markBottomBarItemSelectedByRoute(String route)

So you should do it like this now:

First, navigate to your page:

GoRouter.of(Utils.tabNav.currentContext!).go('/rooms') => you should say also instead go(RoomsPage.route).

Then, update the bottom bar item with the same route:

ref.read(bottomBarVMProvider.notifier).markBottomBarItemSelectedByRoute(RoomsPage.route);

And you should be good to go.