Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
## 3.0.1

- Updates README.md to use the mixin `with _$RouteName`.

## 3.0.0

- Route classes now required to use a mixin `with _$RouteName`.
Expand Down
16 changes: 12 additions & 4 deletions packages/go_router_builder/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,8 @@ The code generator can convert simple types like `int` and `enum` to/from the
```dart
enum BookKind { all, popular, recent }

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

Expand Down Expand Up @@ -370,7 +371,8 @@ method of the base class instead of the `build` method:

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

<?code-excerpt "example/lib/readme_excerpts.dart (FancyRoute)"?>
```dart
class FancyRoute extends GoRouteData {
class FancyRoute extends GoRouteData with _$FancyRoute {
const FancyRoute();
@override
CustomTransitionPage<void> buildPage(
BuildContext context,
Expand Down Expand Up @@ -421,6 +424,11 @@ Example:
final GlobalKey<NavigatorState> shellNavigatorKey = GlobalKey<NavigatorState>();
final GlobalKey<NavigatorState> rootNavigatorKey = GlobalKey<NavigatorState>();

@TypedShellRoute<MyShellRouteData>(
routes: <TypedRoute<RouteData>>[
TypedGoRoute<MyGoRouteData>(path: 'my-go-route'),
],
)
class MyShellRouteData extends ShellRouteData {
const MyShellRouteData();

Expand All @@ -433,7 +441,7 @@ class MyShellRouteData extends ShellRouteData {
}

// For GoRoutes:
class MyGoRouteData extends GoRouteData {
class MyGoRouteData extends GoRouteData with _$MyGoRouteData {
const MyGoRouteData();

static final GlobalKey<NavigatorState> $parentNavigatorKey = rootNavigatorKey;
Expand Down
18 changes: 14 additions & 4 deletions packages/go_router_builder/example/lib/readme_excerpts.dart
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,8 @@ class HotdogScreen extends StatelessWidget {
// #docregion BookKind
enum BookKind { all, popular, recent }

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

Expand All @@ -332,8 +333,10 @@ class BooksScreen extends StatelessWidget {
}
}

@TypedGoRoute<MyMaterialRouteWithKey>(path: '/my-material-route-with-key')
// #docregion MyMaterialRouteWithKey
class MyMaterialRouteWithKey extends GoRouteData {
class MyMaterialRouteWithKey extends GoRouteData with _$MyMaterialRouteWithKey {
const MyMaterialRouteWithKey();
static const LocalKey _key = ValueKey<String>('my-route-with-key');
@override
MaterialPage<void> buildPage(BuildContext context, GoRouterState state) {
Expand Down Expand Up @@ -373,8 +376,10 @@ class MyShellRoutePage extends StatelessWidget {
}
}

@TypedGoRoute<FancyRoute>(path: '/fancy')
// #docregion FancyRoute
class FancyRoute extends GoRouteData {
class FancyRoute extends GoRouteData with _$FancyRoute {
const FancyRoute();
@override
CustomTransitionPage<void> buildPage(
BuildContext context,
Expand All @@ -395,6 +400,11 @@ class FancyRoute extends GoRouteData {
final GlobalKey<NavigatorState> shellNavigatorKey = GlobalKey<NavigatorState>();
final GlobalKey<NavigatorState> rootNavigatorKey = GlobalKey<NavigatorState>();

@TypedShellRoute<MyShellRouteData>(
routes: <TypedRoute<RouteData>>[
TypedGoRoute<MyGoRouteData>(path: 'my-go-route'),
],
)
class MyShellRouteData extends ShellRouteData {
const MyShellRouteData();

Expand All @@ -407,7 +417,7 @@ class MyShellRouteData extends ShellRouteData {
}

// For GoRoutes:
class MyGoRouteData extends GoRouteData {
class MyGoRouteData extends GoRouteData with _$MyGoRouteData {
const MyGoRouteData();

static final GlobalKey<NavigatorState> $parentNavigatorKey = rootNavigatorKey;
Expand Down
155 changes: 155 additions & 0 deletions packages/go_router_builder/example/lib/readme_excerpts.g.dart

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

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: 3.0.0
version: 3.0.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

Expand Down