From 78cbd5a27113bc6d183ed86c32891d3ed51f51dc Mon Sep 17 00:00:00 2001 From: ValentinVignal Date: Thu, 8 Jun 2023 14:10:31 +0800 Subject: [PATCH 1/4] bug: Include required query parameters in location --- packages/go_router_builder/lib/src/route_config.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/go_router_builder/lib/src/route_config.dart b/packages/go_router_builder/lib/src/route_config.dart index 3e53cb1c427e..693eb4a42cf3 100644 --- a/packages/go_router_builder/lib/src/route_config.dart +++ b/packages/go_router_builder/lib/src/route_config.dart @@ -441,7 +441,7 @@ GoRouteData.\$route( late final List _ctorParams = _ctor.parameters.where((ParameterElement element) { - if (element.isRequired && !element.isExtraField) { + if (_pathParams.contains(element.name)) { return true; } return false; @@ -449,7 +449,7 @@ GoRouteData.\$route( late final List _ctorQueryParams = _ctor.parameters .where((ParameterElement element) => - element.isOptional && !element.isExtraField) + !_pathParams.contains(element.name) && !element.isExtraField) .toList(); ConstructorElement get _ctor { From b8b3edec9a3ead7ca55197db1d7fa4d4a9940a7d Mon Sep 17 00:00:00 2001 From: ValentinVignal Date: Thu, 8 Jun 2023 14:10:38 +0800 Subject: [PATCH 2/4] test: Update the tests --- .../test/test_inputs/_go_router_builder_test_input.dart | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/go_router_builder/test/test_inputs/_go_router_builder_test_input.dart b/packages/go_router_builder/test/test_inputs/_go_router_builder_test_input.dart index 016d2c86518a..b27b1ea91002 100644 --- a/packages/go_router_builder/test/test_inputs/_go_router_builder_test_input.dart +++ b/packages/go_router_builder/test/test_inputs/_go_router_builder_test_input.dart @@ -68,6 +68,9 @@ extension $NullableRequiredParamNotInPathExtension String get location => GoRouteData.$location( 'bob', + queryParams: { + if (id != null) 'id': id!.toString(), + }, ); void go(BuildContext context) => context.go(location); @@ -108,6 +111,9 @@ extension $NonNullableRequiredParamNotInPathExtension String get location => GoRouteData.$location( 'bob', + queryParams: { + 'id': id.toString(), + }, ); void go(BuildContext context) => context.go(location); From fd4a2c4ba3c0551237cea01fbf35bc60788a8773 Mon Sep 17 00:00:00 2001 From: ValentinVignal Date: Thu, 8 Jun 2023 14:10:48 +0800 Subject: [PATCH 3/4] doc: Increase version number --- packages/go_router_builder/CHANGELOG.md | 4 ++++ packages/go_router_builder/pubspec.yaml | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/go_router_builder/CHANGELOG.md b/packages/go_router_builder/CHANGELOG.md index 81a4e7db62f0..a6467293a126 100644 --- a/packages/go_router_builder/CHANGELOG.md +++ b/packages/go_router_builder/CHANGELOG.md @@ -1,3 +1,7 @@ +## 2.1.1 + +* Includes the required/positional parameters in the route location. + ## 2.1.0 * Supports required/positional parameters that are not in the path. diff --git a/packages/go_router_builder/pubspec.yaml b/packages/go_router_builder/pubspec.yaml index 027b79ea2c6f..9f213c1508d2 100644 --- a/packages/go_router_builder/pubspec.yaml +++ b/packages/go_router_builder/pubspec.yaml @@ -2,7 +2,7 @@ name: go_router_builder description: >- A builder that supports generated strongly-typed route helpers for package:go_router -version: 2.1.0 +version: 2.1.1 repository: https://github.com/flutter/packages/tree/main/packages/go_router_builder issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+go_router_builder%22 From 099710bf2ef258eb46f4bb3a103e4d6aa28f86f5 Mon Sep 17 00:00:00 2001 From: Valentin Vignal <32538273+ValentinVignal@users.noreply.github.com> Date: Fri, 9 Jun 2023 10:30:32 +0800 Subject: [PATCH 4/4] Update packages/go_router_builder/CHANGELOG.md Co-authored-by: chunhtai <47866232+chunhtai@users.noreply.github.com> --- packages/go_router_builder/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/go_router_builder/CHANGELOG.md b/packages/go_router_builder/CHANGELOG.md index a6467293a126..ce6210d043fd 100644 --- a/packages/go_router_builder/CHANGELOG.md +++ b/packages/go_router_builder/CHANGELOG.md @@ -1,6 +1,6 @@ ## 2.1.1 -* Includes the required/positional parameters in the route location. +* Fixes a bug that the required/positional parameters are not added to query parameters correctly. ## 2.1.0