[go_router] Fixes a bug in `debugLogDiagnostics` to support StatefulShellRoute (#4177)
PR fixes the following issue:
- https://github.com/flutter/flutter/issues/127957
diff --git a/packages/go_router/CHANGELOG.md b/packages/go_router/CHANGELOG.md
index 173973a..28e8c8d 100644
--- a/packages/go_router/CHANGELOG.md
+++ b/packages/go_router/CHANGELOG.md
@@ -1,3 +1,7 @@
+## 8.0.2
+
+- Fixes a bug in `debugLogDiagnostics` to support StatefulShellRoute.
+
## 8.0.1
- Fixes a link for an example in `path` documentation.
diff --git a/packages/go_router/lib/src/configuration.dart b/packages/go_router/lib/src/configuration.dart
index f2e9d84..bd10649 100644
--- a/packages/go_router/lib/src/configuration.dart
+++ b/packages/go_router/lib/src/configuration.dart
@@ -552,7 +552,7 @@
final String fullPath = concatenatePaths(parentFullpath, route.path);
sb.writeln(' => ${''.padLeft(depth * 2)}$fullPath');
_debugFullPathsFor(route.routes, fullPath, depth + 1, sb);
- } else if (route is ShellRoute) {
+ } else if (route is ShellRouteBase) {
_debugFullPathsFor(route.routes, parentFullpath, depth, sb);
}
}
diff --git a/packages/go_router/pubspec.yaml b/packages/go_router/pubspec.yaml
index 2d152da..f5cd923 100644
--- a/packages/go_router/pubspec.yaml
+++ b/packages/go_router/pubspec.yaml
@@ -1,7 +1,7 @@
name: go_router
description: A declarative router for Flutter based on Navigation 2 supporting
deep linking, data-driven routes and more
-version: 8.0.1
+version: 8.0.2
repository: https://github.com/flutter/packages/tree/main/packages/go_router
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+go_router%22
diff --git a/packages/go_router/test/configuration_test.dart b/packages/go_router/test/configuration_test.dart
index ac6ff0e..ac4d1ed 100644
--- a/packages/go_router/test/configuration_test.dart
+++ b/packages/go_router/test/configuration_test.dart
@@ -1037,6 +1037,33 @@
),
],
),
+ GoRoute(
+ path: '/g',
+ builder: _mockScreenBuilder,
+ routes: <RouteBase>[
+ StatefulShellRoute.indexedStack(
+ builder: _mockIndexedStackShellBuilder,
+ branches: <StatefulShellBranch>[
+ StatefulShellBranch(
+ routes: <RouteBase>[
+ GoRoute(
+ path: 'h',
+ builder: _mockScreenBuilder,
+ ),
+ ],
+ ),
+ StatefulShellBranch(
+ routes: <RouteBase>[
+ GoRoute(
+ path: 'i',
+ builder: _mockScreenBuilder,
+ ),
+ ],
+ ),
+ ],
+ ),
+ ],
+ ),
],
redirectLimit: 10,
topRedirect: (BuildContext context, GoRouterState state) {
@@ -1049,7 +1076,10 @@
' => /a/c\n'
' => /d\n'
' => /d/e\n'
- ' => /d/e/f\n',
+ ' => /d/e/f\n'
+ ' => /g\n'
+ ' => /g/h\n'
+ ' => /g/i\n',
);
},
);
@@ -1069,3 +1099,7 @@
Widget _mockShellBuilder(
BuildContext context, GoRouterState state, Widget child) =>
child;
+
+Widget _mockIndexedStackShellBuilder(BuildContext context, GoRouterState state,
+ StatefulNavigationShell shell) =>
+ shell;