jonataslaw / getx

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

Get.toNamed doesn't work in Nested Navigation #1130

Open knnkrt opened 3 years ago

knnkrt commented 3 years ago

Get.to(AnyPage(), id: 1); works perfectly in Nested Navigation but, Get.toNamed('/any', id: 1); doesn't work and returning existing page. @jonataslaw

Katekko commented 3 years ago

How are you making your routes?

knnkrt commented 3 years ago

How are you making your routes?

image image image image

eduardoflorence commented 3 years ago

See my example with BottomNavigationBar: https://github.com/jonataslaw/getx/issues/799#issuecomment-730719165

gordonlotter commented 3 years ago

I'd like to add to this and ask, how can I keep my nested pages state when navigating away and coming back. For example scroll to point 100 on page "/settings", go to another tab on navbar and back to settings then the scroll position should be the same? #799 works great but my pages return to previous state. I've read #23 that GetObserver might be an option...

gordonlotter commented 3 years ago

Doing the below keeps my pages state when navigating. Works really well.

Scaffold(
          extendBodyBehindAppBar: true,
          extendBody: true,
          body: PageView(
            key: PageStorageKey('storage-key'),
            controller: Get.find<NavigationController>().pageController,
            scrollDirection: Axis.horizontal,
            //physics: NeverScrollableScrollPhysics(),
            pageSnapping: true,
            children: Get.find<NavigationController>().pageWidgets,
          ),

Adding Navigator with a Get.nestedKey(1) key and using Get.to(() => page, id:1, transition: Transition.cupertino); to navigate to nested pages causes my pages to reload when onGenerateRoute: is called.

The reason I would like to combine these 2, PageView and Navigator, so that my pages state stay as is when navigating away and returning and also my nested subpages load behind my navbar, navbar is always visible. But combining the 2 is not successful so far.

Any help would really be appreciated. Any other solution would also be great.

loic-hamdi commented 3 years ago

@gordonlotter I am stuck on creating a working nested navigation https://github.com/jonataslaw/getx/issues/1157#issue-823654841 and can't find any solution. Would you mind sharing a gist of your nested navigation implementation please ?

minhdtb commented 2 years ago

pump this, I got the same issue

tva77 commented 2 years ago

same issue

AnneAre commented 2 years ago

same issue

Sumit258000 commented 1 year ago

Same issue.

kulame commented 1 year ago

same issue too

gaalha commented 3 months ago

Same issue, has anyone found a solution?