-
Notifications
You must be signed in to change notification settings - Fork 29.2k
Description
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(),
),
]),
]
)
])
]);