getx icon indicating copy to clipboard operation
getx copied to clipboard

Get.toNamed doesn't work in Nested Navigation

Open knnkrt opened this issue 4 years ago • 12 comments

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

knnkrt avatar Feb 28 '21 22:02 knnkrt

How are you making your routes?

Katekko avatar Mar 01 '21 13:03 Katekko

How are you making your routes?

image image image image

knnkrt avatar Mar 01 '21 13:03 knnkrt

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

eduardoflorence avatar Mar 02 '21 03:03 eduardoflorence

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 avatar Mar 03 '21 23:03 gordonlotter

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.

gordonlotter avatar Mar 08 '21 16:03 gordonlotter

@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 ?

loic-hamdi avatar Mar 08 '21 18:03 loic-hamdi

pump this, I got the same issue

minhdtb avatar Nov 26 '21 04:11 minhdtb

same issue

tva77 avatar Feb 09 '22 21:02 tva77

same issue

AnneAre avatar Mar 31 '22 16:03 AnneAre

Same issue.

Sumit258000 avatar Sep 25 '23 07:09 Sumit258000

same issue too

kulame avatar Oct 03 '23 06:10 kulame

Same issue, has anyone found a solution?

cybergaala avatar Aug 01 '24 17:08 cybergaala