[go_router] removes DebugGoRouteInformation (#2713)
diff --git a/packages/go_router/CHANGELOG.md b/packages/go_router/CHANGELOG.md
index 2549c4d..49da632 100644
--- a/packages/go_router/CHANGELOG.md
+++ b/packages/go_router/CHANGELOG.md
@@ -1,3 +1,7 @@
+## 5.1.1
+
+- Removes DebugGoRouteInformation.
+
## 5.1.0
- Removes urlPathStrategy completely, which should have been done in v5.0.0 but some code remained mistakenly.
diff --git a/packages/go_router/lib/src/information_provider.dart b/packages/go_router/lib/src/information_provider.dart
index 207ec45..7d8ee4f 100644
--- a/packages/go_router/lib/src/information_provider.dart
+++ b/packages/go_router/lib/src/information_provider.dart
@@ -5,7 +5,6 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart';
-import 'parser.dart';
/// The [RouteInformationProvider] created by go_router.
class GoRouteInformationProvider extends RouteInformationProvider
@@ -44,10 +43,7 @@
}
@override
- RouteInformation get value => DebugGoRouteInformation(
- location: _value.location,
- state: _value.state,
- );
+ RouteInformation get value => _value;
RouteInformation _value;
set value(RouteInformation other) {
@@ -110,10 +106,3 @@
return SynchronousFuture<bool>(true);
}
}
-
-/// A debug class that is used for asserting the [GoRouteInformationProvider] is
-/// in use with the [GoRouteInformationParser].
-class DebugGoRouteInformation extends RouteInformation {
- /// Creates a [DebugGoRouteInformation].
- const DebugGoRouteInformation({super.location, super.state});
-}
diff --git a/packages/go_router/lib/src/parser.dart b/packages/go_router/lib/src/parser.dart
index 7c7d1de..61a89b8 100644
--- a/packages/go_router/lib/src/parser.dart
+++ b/packages/go_router/lib/src/parser.dart
@@ -53,17 +53,6 @@
RouteInformation routeInformation,
BuildContext context,
) {
- assert(() {
- if (debugRequireGoRouteInformationProvider) {
- assert(
- routeInformation is DebugGoRouteInformation,
- 'This GoRouteInformationParser needs to be used with '
- 'GoRouteInformationProvider, did you forget to pass in '
- 'GoRouter.routeInformationProvider to the Router constructor?',
- );
- }
- return true;
- }());
late final RouteMatchList initialMatches;
try {
initialMatches = matcher.findMatch(routeInformation.location!,
diff --git a/packages/go_router/lib/src/router.dart b/packages/go_router/lib/src/router.dart
index 69ecf41..cc16088 100644
--- a/packages/go_router/lib/src/router.dart
+++ b/packages/go_router/lib/src/router.dart
@@ -186,7 +186,7 @@
}());
_routeInformationParser
.parseRouteInformationWithDependencies(
- DebugGoRouteInformation(location: location, state: extra),
+ RouteInformation(location: location, state: extra),
// TODO(chunhtai): avoid accessing the context directly through global key.
// https://github.com/flutter/flutter/issues/99112
_routerDelegate.navigatorKey.currentContext!,
@@ -218,7 +218,7 @@
void replace(String location, {Object? extra}) {
routeInformationParser
.parseRouteInformationWithDependencies(
- DebugGoRouteInformation(location: location, state: extra),
+ RouteInformation(location: location, state: extra),
// TODO(chunhtai): avoid accessing the context directly through global key.
// https://github.com/flutter/flutter/issues/99112
_routerDelegate.navigatorKey.currentContext!,
diff --git a/packages/go_router/pubspec.yaml b/packages/go_router/pubspec.yaml
index e0a7c08..f2c4705 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: 5.1.0
+version: 5.1.1
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/parser_test.dart b/packages/go_router/test/parser_test.dart
index 0165466..6e3c0c6 100644
--- a/packages/go_router/test/parser_test.dart
+++ b/packages/go_router/test/parser_test.dart
@@ -6,7 +6,6 @@
import 'package:flutter_test/flutter_test.dart';
import 'package:go_router/go_router.dart';
import 'package:go_router/src/configuration.dart';
-import 'package:go_router/src/information_provider.dart';
import 'package:go_router/src/match.dart';
import 'package:go_router/src/matching.dart';
import 'package:go_router/src/parser.dart';
@@ -54,7 +53,7 @@
RouteMatchList matchesObj =
await parser.parseRouteInformationWithDependencies(
- const DebugGoRouteInformation(location: '/'), context);
+ const RouteInformation(location: '/'), context);
List<RouteMatch> matches = matchesObj.matches;
expect(matches.length, 1);
expect(matches[0].queryParams.isEmpty, isTrue);
@@ -65,8 +64,7 @@
final Object extra = Object();
matchesObj = await parser.parseRouteInformationWithDependencies(
- DebugGoRouteInformation(location: '/abc?def=ghi', state: extra),
- context);
+ RouteInformation(location: '/abc?def=ghi', state: extra), context);
matches = matchesObj.matches;
expect(matches.length, 2);
expect(matches[0].queryParams.length, 1);
@@ -194,7 +192,7 @@
final RouteMatchList matchesObj =
await parser.parseRouteInformationWithDependencies(
- const DebugGoRouteInformation(location: '/def'), context);
+ const RouteInformation(location: '/def'), context);
final List<RouteMatch> matches = matchesObj.matches;
expect(matches.length, 1);
expect(matches[0].queryParams.isEmpty, isTrue);
@@ -229,8 +227,7 @@
final BuildContext context = tester.element(find.byType(Router<Object>));
final RouteMatchList matchesObj =
await parser.parseRouteInformationWithDependencies(
- const DebugGoRouteInformation(location: '/123/family/456'),
- context);
+ const RouteInformation(location: '/123/family/456'), context);
final List<RouteMatch> matches = matchesObj.matches;
expect(matches.length, 2);
@@ -278,7 +275,7 @@
final BuildContext context = tester.element(find.byType(Router<Object>));
final RouteMatchList matchesObj =
await parser.parseRouteInformationWithDependencies(
- const DebugGoRouteInformation(location: '/random/uri'), context);
+ const RouteInformation(location: '/random/uri'), context);
final List<RouteMatch> matches = matchesObj.matches;
expect(matches.length, 2);
@@ -319,7 +316,7 @@
final BuildContext context = tester.element(find.byType(Router<Object>));
final RouteMatchList matchesObj =
await parser.parseRouteInformationWithDependencies(
- const DebugGoRouteInformation(location: '/redirect'), context);
+ const RouteInformation(location: '/redirect'), context);
final List<RouteMatch> matches = matchesObj.matches;
expect(matches.length, 2);
@@ -349,8 +346,7 @@
final BuildContext context = tester.element(find.byType(Router<Object>));
expect(() async {
await parser.parseRouteInformationWithDependencies(
- const DebugGoRouteInformation(location: '::Not valid URI::'),
- context);
+ const RouteInformation(location: '::Not valid URI::'), context);
}, throwsA(isA<FormatException>()));
});
@@ -373,7 +369,7 @@
final BuildContext context = tester.element(find.byType(Router<Object>));
final RouteMatchList matchesObj =
await parser.parseRouteInformationWithDependencies(
- const DebugGoRouteInformation(location: '/abd'), context);
+ const RouteInformation(location: '/abd'), context);
final List<RouteMatch> matches = matchesObj.matches;
expect(matches, hasLength(1));
@@ -417,7 +413,7 @@
final BuildContext context = tester.element(find.byType(Router<Object>));
final RouteMatchList matchesObj =
await parser.parseRouteInformationWithDependencies(
- const DebugGoRouteInformation(location: '/a'), context);
+ const RouteInformation(location: '/a'), context);
final List<RouteMatch> matches = matchesObj.matches;
expect(matches, hasLength(2));