Skip to content

[go_router] ShellRoutes break iOS swipe back navigation #120353

@mnefzger

Description

@mnefzger

go_router version: 6.0.4
flutter version: 3.3.9

Hi go_router team,
we experience an unexpected behaviour when it comes to using GoRouter with ShellRoutes in combination with the iOS "swipe to go back" gesture. The navigation seems to skip over all routes wrapped in the ShellRoute. Everything works as expected with the Android "swipe to go back" gesture.

Steps to Reproduce

With the below code sample using a ShellRoute, navigate to sub-page "AcknowledgementsPage" and then "swipe to go back" on iOS.

Expected results: Navigation goes back only one page to "AboutThisAppPage".

Actual results: Navigation skips any page wrapped in ShellRoute, goes back to "HomePage".

Code sample With this example, the "swipe to go back" works as expected:
GoRouter(
      initialLocation: '/home',
      routes: [
        GoRoute(
          path: '/home',
          name: HomePage.routeName,
          pageBuilder: const HomePage(),
          routes: [
             GoRoute(
                path: 'about',
                name: AboutThisAppPage.routeName,
                pageBuilder: const AboutThisAppPage(),
                routes: [
                  GoRoute(
                      path: 'acknowledgements',
                      name: AcknowledgementsPage.routeName,
                      pageBuilder: const AcknowledgementsPage(),
                  ),
                ]),
          ])
       ]);

When including a ShellRoute, swipe to go back from "AcknowledgementsPage" will go back to "HomePage" instead of "AboutThisAppPage".

GoRouter(
    initialLocation: '/home', 
    routes: [
     GoRoute(
        path: '/home',
        name: HomePage.routeName,
        pageBuilder: const HomePage(),
        routes: [
          // This minimal ShellRoute does not provide any benefit but is enough to reproduce the unexpected behaviour
          ShellRoute(
            builder: (context, state, child) {
              return child;
            },
            routes: [
              GoRoute(
                  path: 'about',
                  name: AboutThisAppPage.routeName,
                  pageBuilder: const AboutThisAppPage(),
                  routes: [
                    GoRoute(
                      path: 'acknowledgements',
                      name: AcknowledgementsPage.routeName,
                      pageBuilder: const AcknowledgementsPage(),
                    ),
                  ]),
            ]
          )
        ])
  ]);

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listcustomer: crowdAffects or could affect many people, though not necessarily a specific customer.found in release: 3.7Found to occur in 3.7found in release: 3.8Found to occur in 3.8has reproducible stepsThe issue has been confirmed reproducible and is ready to work onp: go_routerThe go_router packagepackageflutter/packages repository. See also p: labels.platform-iosiOS applications specificallyteam-frameworkOwned by Framework teamtriaged-frameworkTriaged by Framework team

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions