Nested Navigation using Getx Flutter

Viewed 29

I want to implement Nested navigation using GetNavigator, but can't find any proper guide. Anyone with a proper solution ?

1 Answers

You can add children in the GetPage to nest the page inside the parent route.

Example

GetPage(
      name: '/dashboard', 
      page: () => Dashboard(), 
      middlewares: [
        AuthGuard(),
      ],
      children: [
        GetPage(
          name: '/products',
          page: () => Products(),
        ),
        GetPage(
          name: '/favorites',
          page: () => Favorites(),
        ),
        GetPage(
          name: '/orders',
          page: () => Orders(),
        ),
    ]),

Then to navigate to products page, you can do

Get.toNamed('/dashboard/products');
Related