[go_router] Fix redirection log (#3032)
* add toString to RouteMatchList
* use more explicit toString
* add test
* fix formatting
* update version and changelog
diff --git a/packages/go_router/CHANGELOG.md b/packages/go_router/CHANGELOG.md
index fc741b3..716952b 100644
--- a/packages/go_router/CHANGELOG.md
+++ b/packages/go_router/CHANGELOG.md
@@ -1,3 +1,7 @@
+## 6.0.4
+
+- Fixes redirection info log.
+
## 6.0.3
- Makes `CustomTransitionPage.barrierDismissible` work
diff --git a/packages/go_router/lib/src/matching.dart b/packages/go_router/lib/src/matching.dart
index 140c1d1..86e5702 100644
--- a/packages/go_router/lib/src/matching.dart
+++ b/packages/go_router/lib/src/matching.dart
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+import 'package:flutter/foundation.dart';
import 'package:flutter/widgets.dart';
import 'configuration.dart';
@@ -134,6 +135,11 @@
/// Returns the error that this match intends to display.
Exception? get error => matches.first.error;
+
+ @override
+ String toString() {
+ return '${objectRuntimeType(this, 'RouteMatchList')}($fullpath)';
+ }
}
/// An error that occurred during matching.
diff --git a/packages/go_router/pubspec.yaml b/packages/go_router/pubspec.yaml
index e29a5f0..fcac2ba 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: 6.0.3
+version: 6.0.4
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/matching_test.dart b/packages/go_router/test/matching_test.dart
new file mode 100644
index 0000000..c92533b
--- /dev/null
+++ b/packages/go_router/test/matching_test.dart
@@ -0,0 +1,30 @@
+// Copyright 2013 The Flutter Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+import 'package:flutter/widgets.dart';
+import 'package:flutter_test/flutter_test.dart';
+import 'package:go_router/src/configuration.dart';
+import 'package:go_router/src/matching.dart';
+import 'package:go_router/src/router.dart';
+
+import 'test_helpers.dart';
+
+void main() {
+ testWidgets('RouteMatchList toString prints the fullPath',
+ (WidgetTester tester) async {
+ final List<GoRoute> routes = <GoRoute>[
+ GoRoute(
+ path: '/page-0',
+ builder: (BuildContext context, GoRouterState state) =>
+ const Placeholder()),
+ ];
+
+ final GoRouter router = await createRouter(routes, tester);
+ router.go('/page-0');
+ await tester.pumpAndSettle();
+
+ final RouteMatchList matches = router.routerDelegate.matches;
+ expect(matches.toString(), contains('/page-0'));
+ });
+}