Skip to content

Commit 715a0a5

Browse files
[go_router_builder] Update readme to use mixin with _$RouteName (#9423)
Part of flutter/flutter#170574 ## 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 14a562e commit 715a0a5

File tree

5 files changed

+186
-9
lines changed

5 files changed

+186
-9
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+
## 3.0.1
2+
3+
- Updates README.md to use the mixin `with _$RouteName`.
4+
15
## 3.0.0
26

37
- Route classes now required to use a mixin `with _$RouteName`.

packages/go_router_builder/README.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,8 @@ The code generator can convert simple types like `int` and `enum` to/from the
341341
```dart
342342
enum BookKind { all, popular, recent }
343343
344-
class BooksRoute extends GoRouteData {
344+
@TypedGoRoute<BooksRoute>(path: '/books')
345+
class BooksRoute extends GoRouteData with _$BooksRoute {
345346
BooksRoute({this.kind = BookKind.popular});
346347
final BookKind kind;
347348
@@ -370,7 +371,8 @@ method of the base class instead of the `build` method:
370371

371372
<?code-excerpt "example/lib/readme_excerpts.dart (MyMaterialRouteWithKey)"?>
372373
```dart
373-
class MyMaterialRouteWithKey extends GoRouteData {
374+
class MyMaterialRouteWithKey extends GoRouteData with _$MyMaterialRouteWithKey {
375+
const MyMaterialRouteWithKey();
374376
static const LocalKey _key = ValueKey<String>('my-route-with-key');
375377
@override
376378
MaterialPage<void> buildPage(BuildContext context, GoRouterState state) {
@@ -388,7 +390,8 @@ Overriding the `buildPage` method is also useful for custom transitions:
388390

389391
<?code-excerpt "example/lib/readme_excerpts.dart (FancyRoute)"?>
390392
```dart
391-
class FancyRoute extends GoRouteData {
393+
class FancyRoute extends GoRouteData with _$FancyRoute {
394+
const FancyRoute();
392395
@override
393396
CustomTransitionPage<void> buildPage(
394397
BuildContext context,
@@ -421,6 +424,11 @@ Example:
421424
final GlobalKey<NavigatorState> shellNavigatorKey = GlobalKey<NavigatorState>();
422425
final GlobalKey<NavigatorState> rootNavigatorKey = GlobalKey<NavigatorState>();
423426
427+
@TypedShellRoute<MyShellRouteData>(
428+
routes: <TypedRoute<RouteData>>[
429+
TypedGoRoute<MyGoRouteData>(path: 'my-go-route'),
430+
],
431+
)
424432
class MyShellRouteData extends ShellRouteData {
425433
const MyShellRouteData();
426434
@@ -433,7 +441,7 @@ class MyShellRouteData extends ShellRouteData {
433441
}
434442
435443
// For GoRoutes:
436-
class MyGoRouteData extends GoRouteData {
444+
class MyGoRouteData extends GoRouteData with _$MyGoRouteData {
437445
const MyGoRouteData();
438446
439447
static final GlobalKey<NavigatorState> $parentNavigatorKey = rootNavigatorKey;

packages/go_router_builder/example/lib/readme_excerpts.dart

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,8 @@ class HotdogScreen extends StatelessWidget {
307307
// #docregion BookKind
308308
enum BookKind { all, popular, recent }
309309

310-
class BooksRoute extends GoRouteData {
310+
@TypedGoRoute<BooksRoute>(path: '/books')
311+
class BooksRoute extends GoRouteData with _$BooksRoute {
311312
BooksRoute({this.kind = BookKind.popular});
312313
final BookKind kind;
313314

@@ -332,8 +333,10 @@ class BooksScreen extends StatelessWidget {
332333
}
333334
}
334335

336+
@TypedGoRoute<MyMaterialRouteWithKey>(path: '/my-material-route-with-key')
335337
// #docregion MyMaterialRouteWithKey
336-
class MyMaterialRouteWithKey extends GoRouteData {
338+
class MyMaterialRouteWithKey extends GoRouteData with _$MyMaterialRouteWithKey {
339+
const MyMaterialRouteWithKey();
337340
static const LocalKey _key = ValueKey<String>('my-route-with-key');
338341
@override
339342
MaterialPage<void> buildPage(BuildContext context, GoRouterState state) {
@@ -373,8 +376,10 @@ class MyShellRoutePage extends StatelessWidget {
373376
}
374377
}
375378

379+
@TypedGoRoute<FancyRoute>(path: '/fancy')
376380
// #docregion FancyRoute
377-
class FancyRoute extends GoRouteData {
381+
class FancyRoute extends GoRouteData with _$FancyRoute {
382+
const FancyRoute();
378383
@override
379384
CustomTransitionPage<void> buildPage(
380385
BuildContext context,
@@ -395,6 +400,11 @@ class FancyRoute extends GoRouteData {
395400
final GlobalKey<NavigatorState> shellNavigatorKey = GlobalKey<NavigatorState>();
396401
final GlobalKey<NavigatorState> rootNavigatorKey = GlobalKey<NavigatorState>();
397402

403+
@TypedShellRoute<MyShellRouteData>(
404+
routes: <TypedRoute<RouteData>>[
405+
TypedGoRoute<MyGoRouteData>(path: 'my-go-route'),
406+
],
407+
)
398408
class MyShellRouteData extends ShellRouteData {
399409
const MyShellRouteData();
400410

@@ -407,7 +417,7 @@ class MyShellRouteData extends ShellRouteData {
407417
}
408418

409419
// For GoRoutes:
410-
class MyGoRouteData extends GoRouteData {
420+
class MyGoRouteData extends GoRouteData with _$MyGoRouteData {
411421
const MyGoRouteData();
412422

413423
static final GlobalKey<NavigatorState> $parentNavigatorKey = rootNavigatorKey;

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

Lines changed: 155 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/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: 3.0.0
5+
version: 3.0.1
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

0 commit comments

Comments
 (0)