Skip to content

Commit

Permalink
[go_router_builder] Added replace methods to the generated routes. (f…
Browse files Browse the repository at this point in the history
…lutter#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.
  • Loading branch information
bvoq authored Jun 27, 2023
1 parent f89ce02 commit 1984c73
Show file tree
Hide file tree
Showing 10 changed files with 93 additions and 1 deletion.
4 changes: 4 additions & 0 deletions packages/go_router_builder/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 2.2.0

* Adds replace methods to the generated routes.

## 2.1.1

* Fixes a bug that the required/positional parameters are not added to query parameters correctly.
Expand Down
26 changes: 26 additions & 0 deletions packages/go_router_builder/example/lib/all_types.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions packages/go_router_builder/example/lib/extra_example.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions packages/go_router_builder/example/lib/main.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions packages/go_router_builder/example/lib/simple_example.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions packages/go_router_builder/lib/src/route_config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,9 @@ extension $_extensionName on $_className {
void pushReplacement(BuildContext context) =>
context.pushReplacement(location${_extraParam != null ? ', extra: $extraFieldName' : ''});
void replace(BuildContext context) =>
context.replace(location${_extraParam != null ? ', extra: $extraFieldName' : ''});
}
''';
}
Expand Down
2 changes: 1 addition & 1 deletion packages/go_router_builder/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.1
version: 2.2.0
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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ extension $NullableRequiredParamNotInPathExtension
void pushReplacement(BuildContext context) =>
context.pushReplacement(location);
void replace(BuildContext context) => context.replace(location);
}
T? _$convertMapValue<T>(
Expand Down Expand Up @@ -122,6 +124,8 @@ extension $NonNullableRequiredParamNotInPathExtension
void pushReplacement(BuildContext context) =>
context.pushReplacement(location);
void replace(BuildContext context) => context.replace(location);
}
''')
@TypedGoRoute<NonNullableRequiredParamNotInPath>(path: 'bob')
Expand Down Expand Up @@ -151,6 +155,8 @@ extension $EnumParamExtension on EnumParam {
void pushReplacement(BuildContext context) =>
context.pushReplacement(location);
void replace(BuildContext context) => context.replace(location);
}
const _$EnumTestEnumMap = {
Expand Down Expand Up @@ -204,6 +210,8 @@ extension $DefaultValueRouteExtension on DefaultValueRoute {
void pushReplacement(BuildContext context) =>
context.pushReplacement(location);
void replace(BuildContext context) => context.replace(location);
}
T? _$convertMapValue<T>(
Expand Down Expand Up @@ -248,6 +256,9 @@ extension $ExtraValueRouteExtension on ExtraValueRoute {
void pushReplacement(BuildContext context) =>
context.pushReplacement(location, extra: $extra);
void replace(BuildContext context) =>
context.replace(location, extra: $extra);
}
T? _$convertMapValue<T>(
Expand Down Expand Up @@ -289,6 +300,9 @@ extension $RequiredExtraValueRouteExtension on RequiredExtraValueRoute {
void pushReplacement(BuildContext context) =>
context.pushReplacement(location, extra: $extra);
void replace(BuildContext context) =>
context.replace(location, extra: $extra);
}
''')
@TypedGoRoute<RequiredExtraValueRoute>(path: '/default-value-route')
Expand Down Expand Up @@ -335,6 +349,8 @@ extension $IterableWithEnumRouteExtension on IterableWithEnumRoute {
void pushReplacement(BuildContext context) =>
context.pushReplacement(location);
void replace(BuildContext context) => context.replace(location);
}
const _$EnumOnlyUsedInIterableEnumMap = {
Expand Down Expand Up @@ -388,6 +404,8 @@ extension $IterableDefaultValueRouteExtension on IterableDefaultValueRoute {
void pushReplacement(BuildContext context) =>
context.pushReplacement(location);
void replace(BuildContext context) => context.replace(location);
}
''')
@TypedGoRoute<IterableDefaultValueRoute>(path: '/iterable-default-value-route')
Expand Down Expand Up @@ -416,6 +434,8 @@ extension $NamedRouteExtension on NamedRoute {
void pushReplacement(BuildContext context) =>
context.pushReplacement(location);
void replace(BuildContext context) => context.replace(location);
}
''')
@TypedGoRoute<NamedRoute>(path: '/named-route', name: 'namedRoute')
Expand All @@ -442,6 +462,8 @@ extension $NamedEscapedRouteExtension on NamedEscapedRoute {
void pushReplacement(BuildContext context) =>
context.pushReplacement(location);
void replace(BuildContext context) => context.replace(location);
}
''')
@TypedGoRoute<NamedEscapedRoute>(path: '/named-route', name: r'named$Route')
Expand Down

0 comments on commit 1984c73

Please sign in to comment.