From f38d9933a80a10ffa4466f1bce84c2ab74fbe3c8 Mon Sep 17 00:00:00 2001 From: ValentinVignal Date: Wed, 16 Apr 2025 23:25:42 +0800 Subject: [PATCH 1/2] Add caseSensitive to TypedGoRoute --- packages/go_router/lib/src/route_data.dart | 12 +++++ packages/go_router/test/route_data_test.dart | 46 ++++++++++++++++++++ 2 files changed, 58 insertions(+) diff --git a/packages/go_router/lib/src/route_data.dart b/packages/go_router/lib/src/route_data.dart index a088cc96652b..473dfbbbcfa0 100644 --- a/packages/go_router/lib/src/route_data.dart +++ b/packages/go_router/lib/src/route_data.dart @@ -369,6 +369,7 @@ class TypedGoRoute extends TypedRoute { required this.path, this.name, this.routes = const >[], + this.caseSensitive = true, }); /// The path that corresponds to this route. @@ -390,6 +391,17 @@ class TypedGoRoute extends TypedRoute { /// /// See [RouteBase.routes]. final List> routes; + + /// Determines whether the route matching is case sensitive. + /// + /// When `true`, the path must match the specified case. For example, + /// a route with `path: '/family/:fid'` will not match `/FaMiLy/f2`. + /// + /// When `false`, the path matching is case insensitive. The route + /// with `path: '/family/:fid'` will match `/FaMiLy/f2`. + /// + /// Defaults to `true`. + final bool caseSensitive; } /// A superclass for each typed shell route descendant diff --git a/packages/go_router/test/route_data_test.dart b/packages/go_router/test/route_data_test.dart index 757b1b054dd6..609a5fc131ca 100644 --- a/packages/go_router/test/route_data_test.dart +++ b/packages/go_router/test/route_data_test.dart @@ -492,4 +492,50 @@ void main() { expect(find.byKey(const Key('buildPage')), findsNothing); }, ); + test('TypedGoRoute with default parameters', () { + const TypedGoRoute typedGoRoute = TypedGoRoute( + path: '/path', + ); + + expect(typedGoRoute.path, '/path'); + expect(typedGoRoute.name, isNull); + expect(typedGoRoute.caseSensitive, true); + expect(typedGoRoute.routes, isEmpty); + }); + + test('TypedGoRoute with provided parameters', () { + const TypedGoRoute typedGoRoute = TypedGoRoute( + path: '/path', + name: 'name', + caseSensitive: false, + routes: >[ + TypedGoRoute( + path: 'sub-path', + name: 'subName', + caseSensitive: false, + ), + ], + ); + + expect(typedGoRoute.path, '/path'); + expect(typedGoRoute.name, 'name'); + expect(typedGoRoute.caseSensitive, false); + expect(typedGoRoute.routes, hasLength(1)); + expect( + typedGoRoute.routes.single, + isA>() + .having((TypedGoRoute route) => route.path, 'path', + 'sub-path') + .having( + (TypedGoRoute route) => route.name, + 'name', + 'subName', + ) + .having( + (TypedGoRoute route) => route.caseSensitive, + 'caseSensitive', + false, + ), + ); + }); } From a9598ffafdcac89c96a6398bcb23631aed7e71a4 Mon Sep 17 00:00:00 2001 From: ValentinVignal Date: Thu, 17 Apr 2025 09:31:20 +0800 Subject: [PATCH 2/2] Update version --- packages/go_router/CHANGELOG.md | 4 ++++ packages/go_router/pubspec.yaml | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/go_router/CHANGELOG.md b/packages/go_router/CHANGELOG.md index 2c80a43d6e1d..f9209469ddc9 100644 --- a/packages/go_router/CHANGELOG.md +++ b/packages/go_router/CHANGELOG.md @@ -1,3 +1,7 @@ +## 15.1.0 + +- Adds `caseSensitive` to `TypedGoRoute`. + ## 15.0.0 - **BREAKING CHANGE** diff --git a/packages/go_router/pubspec.yaml b/packages/go_router/pubspec.yaml index 90bdc10f5e9b..49c766d89439 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: 15.0.0 +version: 15.1.0 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