Skip to content

Commit 3db5adc

Browse files
authored
[go_router_builder] Change mixin name (#9626)
Fixes [#170650](flutter/flutter#170650) This PR fixes workflows that relied on putting child routes in files different than parent files, which resulted in the (private) mixin being generated in a different file than the route itself. To avoid releasing a new major version in such a short period, this PR makes the mixin public only if needed. Admittedly makes the behavior somewhat unexpected for the user. @chunhtai @hannah-hyj I will leave that decision for you, whether that's ok or I should make it always public and release a major version instead. Since this change just fixes a use-case that already didn't compile in 3.x.x, this PR doesn't bump the major version. ## Pre-Review Checklist [^1]: Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling.
1 parent 0b62965 commit 3db5adc

File tree

77 files changed

+420
-401
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+420
-401
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+
## 4.0.0
2+
3+
- Make Route mixins public.
4+
15
## 3.3.1
26

37
- Fixes warnings in generated code of iterable parameters.

packages/go_router_builder/README.md

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ dart run build_runner build
4141
Read more about using
4242
[`build_runner` on pub.dev](https://pub.dev/packages/build_runner).
4343

44+
## Migration Guides
45+
- [Migrating to 4.0.0](https://flutter.dev/go/go-router-builder-v4-breaking-changes).
46+
4447
## Overview
4548

4649
`go_router` fundamentally relies on the ability to match a string-based location
@@ -86,7 +89,7 @@ method.
8689

8790
<?code-excerpt "example/lib/readme_excerpts.dart (HomeRoute)"?>
8891
```dart
89-
class HomeRoute extends GoRouteData with _$HomeRoute {
92+
class HomeRoute extends GoRouteData with $HomeRoute {
9093
const HomeRoute();
9194
9295
@override
@@ -106,7 +109,7 @@ The tree of routes is defined as an attribute on each of the top-level routes:
106109
TypedGoRoute<FamilyRoute>(path: 'family/:fid'),
107110
],
108111
)
109-
class HomeRoute extends GoRouteData with _$HomeRoute {
112+
class HomeRoute extends GoRouteData with $HomeRoute {
110113
const HomeRoute();
111114
112115
@override
@@ -122,7 +125,7 @@ class RedirectRoute extends GoRouteData {
122125
}
123126
124127
@TypedGoRoute<LoginRoute>(path: '/login')
125-
class LoginRoute extends GoRouteData with _$LoginRoute {
128+
class LoginRoute extends GoRouteData with $LoginRoute {
126129
LoginRoute({this.from});
127130
final String? from;
128131
@@ -210,7 +213,7 @@ Parameters (named or positional) not listed in the path of `TypedGoRoute` indica
210213
<?code-excerpt "example/lib/readme_excerpts.dart (login)"?>
211214
```dart
212215
@TypedGoRoute<LoginRoute>(path: '/login')
213-
class LoginRoute extends GoRouteData with _$LoginRoute {
216+
class LoginRoute extends GoRouteData with $LoginRoute {
214217
LoginRoute({this.from});
215218
final String? from;
216219
@@ -228,7 +231,7 @@ For query parameters with a **non-nullable** type, you can define a default valu
228231
<?code-excerpt "example/lib/readme_excerpts.dart (MyRoute)"?>
229232
```dart
230233
@TypedGoRoute<MyRoute>(path: '/my-route')
231-
class MyRoute extends GoRouteData with _$MyRoute {
234+
class MyRoute extends GoRouteData with $MyRoute {
232235
MyRoute({this.queryParameter = 'defaultValue'});
233236
final String queryParameter;
234237
@@ -249,7 +252,7 @@ parameter with the special name `$extra`:
249252

250253
<?code-excerpt "example/lib/readme_excerpts.dart (PersonRouteWithExtra)"?>
251254
```dart
252-
class PersonRouteWithExtra extends GoRouteData with _$PersonRouteWithExtra {
255+
class PersonRouteWithExtra extends GoRouteData with $PersonRouteWithExtra {
253256
PersonRouteWithExtra(this.$extra);
254257
final Person? $extra;
255258
@@ -281,7 +284,7 @@ You can, of course, combine the use of path, query and $extra parameters:
281284
```dart
282285
@TypedGoRoute<HotdogRouteWithEverything>(path: '/:ketchup')
283286
class HotdogRouteWithEverything extends GoRouteData
284-
with _$HotdogRouteWithEverything {
287+
with $HotdogRouteWithEverything {
285288
HotdogRouteWithEverything(this.ketchup, this.mustard, this.$extra);
286289
final bool ketchup; // A required path parameter.
287290
final String? mustard; // An optional query parameter.
@@ -341,7 +344,7 @@ The code generator can convert simple types like `int`, `enum`, and `extension t
341344
enum BookKind { all, popular, recent }
342345
343346
@TypedGoRoute<BooksRoute>(path: '/books')
344-
class BooksRoute extends GoRouteData with _$BooksRoute {
347+
class BooksRoute extends GoRouteData with $BooksRoute {
345348
BooksRoute({this.kind = BookKind.popular});
346349
final BookKind kind;
347350
@@ -370,7 +373,7 @@ method of the base class instead of the `build` method:
370373

371374
<?code-excerpt "example/lib/readme_excerpts.dart (MyMaterialRouteWithKey)"?>
372375
```dart
373-
class MyMaterialRouteWithKey extends GoRouteData with _$MyMaterialRouteWithKey {
376+
class MyMaterialRouteWithKey extends GoRouteData with $MyMaterialRouteWithKey {
374377
const MyMaterialRouteWithKey();
375378
static const LocalKey _key = ValueKey<String>('my-route-with-key');
376379
@override
@@ -386,7 +389,7 @@ Overriding the `buildPage` method is also useful for custom transitions:
386389

387390
<?code-excerpt "example/lib/readme_excerpts.dart (FancyRoute)"?>
388391
```dart
389-
class FancyRoute extends GoRouteData with _$FancyRoute {
392+
class FancyRoute extends GoRouteData with $FancyRoute {
390393
const FancyRoute();
391394
@override
392395
CustomTransitionPage<void> buildPage(
@@ -442,7 +445,7 @@ class MyShellRouteData extends ShellRouteData {
442445
}
443446
444447
// For GoRoutes:
445-
class MyGoRouteData extends GoRouteData with _$MyGoRouteData {
448+
class MyGoRouteData extends GoRouteData with $MyGoRouteData {
446449
const MyGoRouteData();
447450
448451
static final GlobalKey<NavigatorState> $parentNavigatorKey = rootNavigatorKey;
@@ -463,7 +466,7 @@ Define a relative route by extending `RelativeGoRouteData`.
463466
<?code-excerpt "example/lib/readme_excerpts.dart (relativeRoute)"?>
464467
```dart
465468
@TypedRelativeGoRoute<DetailsRoute>(path: 'details')
466-
class DetailsRoute extends RelativeGoRouteData with _$DetailsRoute {
469+
class DetailsRoute extends RelativeGoRouteData with $DetailsRoute {
467470
const DetailsRoute();
468471
469472
@override

packages/go_router_builder/example/lib/all_extension_types.dart

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ part 'all_extension_types.g.dart';
4040
],
4141
)
4242
@immutable
43-
class AllTypesBaseRoute extends GoRouteData with _$AllTypesBaseRoute {
43+
class AllTypesBaseRoute extends GoRouteData with $AllTypesBaseRoute {
4444
const AllTypesBaseRoute();
4545

4646
@override
@@ -59,7 +59,7 @@ extension type const UriExtension(Uri value) {}
5959
extension type const PersonDetailsExtension(PersonDetails value) {}
6060
extension type const SportDetailsExtension(SportDetails value) {}
6161

62-
class BigIntExtensionRoute extends GoRouteData with _$BigIntExtensionRoute {
62+
class BigIntExtensionRoute extends GoRouteData with $BigIntExtensionRoute {
6363
const BigIntExtensionRoute({
6464
required this.requiredBigIntField,
6565
this.bigIntField,
@@ -82,7 +82,7 @@ class BigIntExtensionRoute extends GoRouteData with _$BigIntExtensionRoute {
8282
);
8383
}
8484

85-
class BoolExtensionRoute extends GoRouteData with _$BoolExtensionRoute {
85+
class BoolExtensionRoute extends GoRouteData with $BoolExtensionRoute {
8686
const BoolExtensionRoute({
8787
required this.requiredBoolField,
8888
this.boolField,
@@ -108,7 +108,7 @@ class BoolExtensionRoute extends GoRouteData with _$BoolExtensionRoute {
108108
);
109109
}
110110

111-
class DateTimeExtensionRoute extends GoRouteData with _$DateTimeExtensionRoute {
111+
class DateTimeExtensionRoute extends GoRouteData with $DateTimeExtensionRoute {
112112
const DateTimeExtensionRoute({
113113
required this.requiredDateTimeField,
114114
this.dateTimeField,
@@ -131,7 +131,7 @@ class DateTimeExtensionRoute extends GoRouteData with _$DateTimeExtensionRoute {
131131
);
132132
}
133133

134-
class DoubleExtensionRoute extends GoRouteData with _$DoubleExtensionRoute {
134+
class DoubleExtensionRoute extends GoRouteData with $DoubleExtensionRoute {
135135
const DoubleExtensionRoute({
136136
required this.requiredDoubleField,
137137
this.doubleField,
@@ -157,7 +157,7 @@ class DoubleExtensionRoute extends GoRouteData with _$DoubleExtensionRoute {
157157
);
158158
}
159159

160-
class IntExtensionRoute extends GoRouteData with _$IntExtensionRoute {
160+
class IntExtensionRoute extends GoRouteData with $IntExtensionRoute {
161161
const IntExtensionRoute({
162162
required this.requiredIntField,
163163
this.intField,
@@ -183,7 +183,7 @@ class IntExtensionRoute extends GoRouteData with _$IntExtensionRoute {
183183
);
184184
}
185185

186-
class NumExtensionRoute extends GoRouteData with _$NumExtensionRoute {
186+
class NumExtensionRoute extends GoRouteData with $NumExtensionRoute {
187187
const NumExtensionRoute({
188188
required this.requiredNumField,
189189
this.numField,
@@ -209,7 +209,7 @@ class NumExtensionRoute extends GoRouteData with _$NumExtensionRoute {
209209
);
210210
}
211211

212-
class EnumExtensionRoute extends GoRouteData with _$EnumExtensionRoute {
212+
class EnumExtensionRoute extends GoRouteData with $EnumExtensionRoute {
213213
const EnumExtensionRoute({
214214
required this.requiredEnumField,
215215
this.enumField,
@@ -239,7 +239,7 @@ class EnumExtensionRoute extends GoRouteData with _$EnumExtensionRoute {
239239
}
240240

241241
class EnhancedEnumExtensionRoute extends GoRouteData
242-
with _$EnhancedEnumExtensionRoute {
242+
with $EnhancedEnumExtensionRoute {
243243
const EnhancedEnumExtensionRoute({
244244
required this.requiredEnumField,
245245
this.enumField,
@@ -268,7 +268,7 @@ class EnhancedEnumExtensionRoute extends GoRouteData
268268
);
269269
}
270270

271-
class StringExtensionRoute extends GoRouteData with _$StringExtensionRoute {
271+
class StringExtensionRoute extends GoRouteData with $StringExtensionRoute {
272272
const StringExtensionRoute({
273273
required this.requiredStringField,
274274
this.stringField,
@@ -294,7 +294,7 @@ class StringExtensionRoute extends GoRouteData with _$StringExtensionRoute {
294294
);
295295
}
296296

297-
class UriExtensionRoute extends GoRouteData with _$UriExtensionRoute {
297+
class UriExtensionRoute extends GoRouteData with $UriExtensionRoute {
298298
const UriExtensionRoute({required this.requiredUriField, this.uriField});
299299

300300
final UriExtension requiredUriField;

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

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

0 commit comments

Comments
 (0)