Skip to content

Commit 1984c73

Browse files
authored
[go_router_builder] Added replace methods to the generated routes. (flutter#4057)
This PR adds replace methods to the generated routes. *List which issues are fixed by this PR. You must list at least one issue.* fixes flutter/flutter#127315 *If you had to change anything in the [flutter/tests] repo, include a link to the migration guide as per the [breaking change policy].* I modified the tests to also check that the replace methods are generated.
1 parent f89ce02 commit 1984c73

File tree

10 files changed

+93
-1
lines changed

10 files changed

+93
-1
lines changed

packages/go_router_builder/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 2.2.0
2+
3+
* Adds replace methods to the generated routes.
4+
15
## 2.1.1
26

37
* Fixes a bug that the required/positional parameters are not added to query parameters correctly.

packages/go_router_builder/example/lib/all_types.g.dart

Lines changed: 26 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/go_router_builder/example/lib/extra_example.g.dart

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/go_router_builder/example/lib/main.g.dart

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/go_router_builder/example/lib/shell_route_example.g.dart

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/go_router_builder/example/lib/shell_route_with_keys_example.g.dart

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/go_router_builder/example/lib/simple_example.g.dart

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/go_router_builder/lib/src/route_config.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,9 @@ extension $_extensionName on $_className {
217217
218218
void pushReplacement(BuildContext context) =>
219219
context.pushReplacement(location${_extraParam != null ? ', extra: $extraFieldName' : ''});
220+
221+
void replace(BuildContext context) =>
222+
context.replace(location${_extraParam != null ? ', extra: $extraFieldName' : ''});
220223
}
221224
''';
222225
}

packages/go_router_builder/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: go_router_builder
22
description: >-
33
A builder that supports generated strongly-typed route helpers for
44
package:go_router
5-
version: 2.1.1
5+
version: 2.2.0
66
repository: https://github.com/flutter/packages/tree/main/packages/go_router_builder
77
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+go_router_builder%22
88

packages/go_router_builder/test/test_inputs/_go_router_builder_test_input.dart

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ extension $NullableRequiredParamNotInPathExtension
7979
8080
void pushReplacement(BuildContext context) =>
8181
context.pushReplacement(location);
82+
83+
void replace(BuildContext context) => context.replace(location);
8284
}
8385
8486
T? _$convertMapValue<T>(
@@ -122,6 +124,8 @@ extension $NonNullableRequiredParamNotInPathExtension
122124
123125
void pushReplacement(BuildContext context) =>
124126
context.pushReplacement(location);
127+
128+
void replace(BuildContext context) => context.replace(location);
125129
}
126130
''')
127131
@TypedGoRoute<NonNullableRequiredParamNotInPath>(path: 'bob')
@@ -151,6 +155,8 @@ extension $EnumParamExtension on EnumParam {
151155
152156
void pushReplacement(BuildContext context) =>
153157
context.pushReplacement(location);
158+
159+
void replace(BuildContext context) => context.replace(location);
154160
}
155161
156162
const _$EnumTestEnumMap = {
@@ -204,6 +210,8 @@ extension $DefaultValueRouteExtension on DefaultValueRoute {
204210
205211
void pushReplacement(BuildContext context) =>
206212
context.pushReplacement(location);
213+
214+
void replace(BuildContext context) => context.replace(location);
207215
}
208216
209217
T? _$convertMapValue<T>(
@@ -248,6 +256,9 @@ extension $ExtraValueRouteExtension on ExtraValueRoute {
248256
249257
void pushReplacement(BuildContext context) =>
250258
context.pushReplacement(location, extra: $extra);
259+
260+
void replace(BuildContext context) =>
261+
context.replace(location, extra: $extra);
251262
}
252263
253264
T? _$convertMapValue<T>(
@@ -289,6 +300,9 @@ extension $RequiredExtraValueRouteExtension on RequiredExtraValueRoute {
289300
290301
void pushReplacement(BuildContext context) =>
291302
context.pushReplacement(location, extra: $extra);
303+
304+
void replace(BuildContext context) =>
305+
context.replace(location, extra: $extra);
292306
}
293307
''')
294308
@TypedGoRoute<RequiredExtraValueRoute>(path: '/default-value-route')
@@ -335,6 +349,8 @@ extension $IterableWithEnumRouteExtension on IterableWithEnumRoute {
335349
336350
void pushReplacement(BuildContext context) =>
337351
context.pushReplacement(location);
352+
353+
void replace(BuildContext context) => context.replace(location);
338354
}
339355
340356
const _$EnumOnlyUsedInIterableEnumMap = {
@@ -388,6 +404,8 @@ extension $IterableDefaultValueRouteExtension on IterableDefaultValueRoute {
388404
389405
void pushReplacement(BuildContext context) =>
390406
context.pushReplacement(location);
407+
408+
void replace(BuildContext context) => context.replace(location);
391409
}
392410
''')
393411
@TypedGoRoute<IterableDefaultValueRoute>(path: '/iterable-default-value-route')
@@ -416,6 +434,8 @@ extension $NamedRouteExtension on NamedRoute {
416434
417435
void pushReplacement(BuildContext context) =>
418436
context.pushReplacement(location);
437+
438+
void replace(BuildContext context) => context.replace(location);
419439
}
420440
''')
421441
@TypedGoRoute<NamedRoute>(path: '/named-route', name: 'namedRoute')
@@ -442,6 +462,8 @@ extension $NamedEscapedRouteExtension on NamedEscapedRoute {
442462
443463
void pushReplacement(BuildContext context) =>
444464
context.pushReplacement(location);
465+
466+
void replace(BuildContext context) => context.replace(location);
445467
}
446468
''')
447469
@TypedGoRoute<NamedEscapedRoute>(path: '/named-route', name: r'named$Route')

0 commit comments

Comments
 (0)