[go_router_builder] Generate replace method in RouteExtension (#2838)
* [go_router_builder] pushReplacement method added
* [go_router_builder] pushReplacement method added to builder test input
diff --git a/packages/go_router_builder/CHANGELOG.md b/packages/go_router_builder/CHANGELOG.md
index 1619329..2b9e741 100644
--- a/packages/go_router_builder/CHANGELOG.md
+++ b/packages/go_router_builder/CHANGELOG.md
@@ -1,3 +1,7 @@
+## 1.1.1
+
+* Support for the generation of the pushReplacement method has been added.
+
## 1.1.0
* Supports default value for the route parameters.
diff --git a/packages/go_router_builder/example/lib/all_types.g.dart b/packages/go_router_builder/example/lib/all_types.g.dart
index 71ab56e..84f652d 100644
--- a/packages/go_router_builder/example/lib/all_types.g.dart
+++ b/packages/go_router_builder/example/lib/all_types.g.dart
@@ -74,6 +74,9 @@
void go(BuildContext context) => context.go(location, extra: this);
void push(BuildContext context) => context.push(location, extra: this);
+
+ void pushReplacement(BuildContext context) =>
+ context.pushReplacement(location, extra: this);
}
extension $BigIntRouteExtension on BigIntRoute {
@@ -93,6 +96,9 @@
void go(BuildContext context) => context.go(location, extra: this);
void push(BuildContext context) => context.push(location, extra: this);
+
+ void pushReplacement(BuildContext context) =>
+ context.pushReplacement(location, extra: this);
}
extension $BoolRouteExtension on BoolRoute {
@@ -120,6 +126,9 @@
void go(BuildContext context) => context.go(location, extra: this);
void push(BuildContext context) => context.push(location, extra: this);
+
+ void pushReplacement(BuildContext context) =>
+ context.pushReplacement(location, extra: this);
}
extension $DateTimeRouteExtension on DateTimeRoute {
@@ -141,6 +150,9 @@
void go(BuildContext context) => context.go(location, extra: this);
void push(BuildContext context) => context.push(location, extra: this);
+
+ void pushReplacement(BuildContext context) =>
+ context.pushReplacement(location, extra: this);
}
extension $DoubleRouteExtension on DoubleRoute {
@@ -168,6 +180,9 @@
void go(BuildContext context) => context.go(location, extra: this);
void push(BuildContext context) => context.push(location, extra: this);
+
+ void pushReplacement(BuildContext context) =>
+ context.pushReplacement(location, extra: this);
}
extension $IntRouteExtension on IntRoute {
@@ -191,6 +206,9 @@
void go(BuildContext context) => context.go(location, extra: this);
void push(BuildContext context) => context.push(location, extra: this);
+
+ void pushReplacement(BuildContext context) =>
+ context.pushReplacement(location, extra: this);
}
extension $NumRouteExtension on NumRoute {
@@ -214,6 +232,9 @@
void go(BuildContext context) => context.go(location, extra: this);
void push(BuildContext context) => context.push(location, extra: this);
+
+ void pushReplacement(BuildContext context) =>
+ context.pushReplacement(location, extra: this);
}
extension $EnumRouteExtension on EnumRoute {
@@ -243,6 +264,9 @@
void go(BuildContext context) => context.go(location, extra: this);
void push(BuildContext context) => context.push(location, extra: this);
+
+ void pushReplacement(BuildContext context) =>
+ context.pushReplacement(location, extra: this);
}
extension $EnhancedEnumRouteExtension on EnhancedEnumRoute {
@@ -272,6 +296,9 @@
void go(BuildContext context) => context.go(location, extra: this);
void push(BuildContext context) => context.push(location, extra: this);
+
+ void pushReplacement(BuildContext context) =>
+ context.pushReplacement(location, extra: this);
}
extension $StringRouteExtension on StringRoute {
@@ -295,6 +322,9 @@
void go(BuildContext context) => context.go(location, extra: this);
void push(BuildContext context) => context.push(location, extra: this);
+
+ void pushReplacement(BuildContext context) =>
+ context.pushReplacement(location, extra: this);
}
extension $UriRouteExtension on UriRoute {
@@ -313,6 +343,9 @@
void go(BuildContext context) => context.go(location, extra: this);
void push(BuildContext context) => context.push(location, extra: this);
+
+ void pushReplacement(BuildContext context) =>
+ context.pushReplacement(location, extra: this);
}
const _$PersonDetailsEnumMap = {
diff --git a/packages/go_router_builder/example/lib/main.g.dart b/packages/go_router_builder/example/lib/main.g.dart
index 0f87baa..74b89bc 100644
--- a/packages/go_router_builder/example/lib/main.g.dart
+++ b/packages/go_router_builder/example/lib/main.g.dart
@@ -46,6 +46,9 @@
void go(BuildContext context) => context.go(location, extra: this);
void push(BuildContext context) => context.push(location, extra: this);
+
+ void pushReplacement(BuildContext context) =>
+ context.pushReplacement(location, extra: this);
}
extension $FamilyRouteExtension on FamilyRoute {
@@ -60,6 +63,9 @@
void go(BuildContext context) => context.go(location, extra: this);
void push(BuildContext context) => context.push(location, extra: this);
+
+ void pushReplacement(BuildContext context) =>
+ context.pushReplacement(location, extra: this);
}
extension $PersonRouteExtension on PersonRoute {
@@ -75,6 +81,9 @@
void go(BuildContext context) => context.go(location, extra: this);
void push(BuildContext context) => context.push(location, extra: this);
+
+ void pushReplacement(BuildContext context) =>
+ context.pushReplacement(location, extra: this);
}
extension $PersonDetailsRouteExtension on PersonDetailsRoute {
@@ -93,6 +102,9 @@
void go(BuildContext context) => context.go(location, extra: this);
void push(BuildContext context) => context.push(location, extra: this);
+
+ void pushReplacement(BuildContext context) =>
+ context.pushReplacement(location, extra: this);
}
const _$PersonDetailsEnumMap = {
@@ -126,4 +138,7 @@
void go(BuildContext context) => context.go(location, extra: this);
void push(BuildContext context) => context.push(location, extra: this);
+
+ void pushReplacement(BuildContext context) =>
+ context.pushReplacement(location, extra: this);
}
diff --git a/packages/go_router_builder/example/lib/simple_example.g.dart b/packages/go_router_builder/example/lib/simple_example.g.dart
index b3ad338..a71180d 100644
--- a/packages/go_router_builder/example/lib/simple_example.g.dart
+++ b/packages/go_router_builder/example/lib/simple_example.g.dart
@@ -33,6 +33,9 @@
void go(BuildContext context) => context.go(location, extra: this);
void push(BuildContext context) => context.push(location, extra: this);
+
+ void pushReplacement(BuildContext context) =>
+ context.pushReplacement(location, extra: this);
}
extension $FamilyRouteExtension on FamilyRoute {
@@ -47,4 +50,7 @@
void go(BuildContext context) => context.go(location, extra: this);
void push(BuildContext context) => context.push(location, extra: this);
+
+ void pushReplacement(BuildContext context) =>
+ context.pushReplacement(location, extra: this);
}
diff --git a/packages/go_router_builder/lib/src/route_config.dart b/packages/go_router_builder/lib/src/route_config.dart
index 75a7a76..38f7a8c 100644
--- a/packages/go_router_builder/lib/src/route_config.dart
+++ b/packages/go_router_builder/lib/src/route_config.dart
@@ -145,6 +145,9 @@
void go(BuildContext context) => context.go(location, extra: this);
void push(BuildContext context) => context.push(location, extra: this);
+
+ void pushReplacement(BuildContext context) =>
+ context.pushReplacement(location, extra: this);
}
''';
diff --git a/packages/go_router_builder/pubspec.yaml b/packages/go_router_builder/pubspec.yaml
index 7ae28ff..b4ae5b1 100644
--- a/packages/go_router_builder/pubspec.yaml
+++ b/packages/go_router_builder/pubspec.yaml
@@ -2,7 +2,7 @@
description: >-
A builder that supports generated strongly-typed route helpers for
package:go_router
-version: 1.1.0
+version: 1.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
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 1777325..c85e8e3 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
@@ -89,6 +89,9 @@
void go(BuildContext context) => context.go(location, extra: this);
void push(BuildContext context) => context.push(location, extra: this);
+
+ void pushReplacement(BuildContext context) =>
+ context.pushReplacement(location, extra: this);
}
const _$EnumTestEnumMap = {
@@ -138,6 +141,9 @@
void go(BuildContext context) => context.go(location, extra: this);
void push(BuildContext context) => context.push(location, extra: this);
+
+ void pushReplacement(BuildContext context) =>
+ context.pushReplacement(location, extra: this);
}
T? _$convertMapValue<T>(