Search code examples
flutterflutter-getxnavigator

Nested Navigation using Getx Flutter


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


Solution

  • 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');