jonataslaw / getx

Open screens/snackbars/dialogs/bottomSheets without context, manage states and inject dependencies easily with Get.
MIT License
10.27k stars 1.61k forks source link

Help with individual Routing to each BottomNavigationBarItem #1998

Open czaku opened 2 years ago

czaku commented 2 years ago

Hi,

I am quite new to flutter and GetX. I am looking for a pattern of how to implement BottomNavigationBar with GetX so that I can specify different routes to navigate to different BottomNavigationBarItems and their relevant Pages. So that when I navigate to certain route I launch that page with BottomNavigationBarItem selected.

Lets say that is my information architecture

DashboardPage with BottomNavigationBar with relevant items:

In routes I have currently specified "DASHBOARD" route with DashboardBinding and DashboardPage. The question is: what is the pattern to specify "HOME", "PROFILE", "SHOP", "SETTINGS" routes so that when I navigate to them I launch DashboardPage but with relevant BottomNavigationBarItem selected and relevant Page loaded? I am struggling to find a single example that showcases that.

ahmednfwela commented 2 years ago

this is quite easy to do with navigator 2.0 see the folder "example_nav2" and use my branch for now since the main branch has bugs: https://github.com/Bdaya-Dev/getx

vcoolish commented 2 years ago

@ahmednfwela how to keep controller state while navigating with bottom nav in example_nav2? Whenever I change the page it calls onDelete() in my controller and page loads from scratch.

ahmednfwela commented 2 years ago

@vcoolish sorry, but I stopped using getx altogether, I am now using injectable and go_router