Skip to content

Commit

Permalink
[go_router_builder] Replace mentions of deprecated buildPage with `…
Browse files Browse the repository at this point in the history
…buildPageWithState` (flutter#2535)
  • Loading branch information
ValentinVignal authored Sep 15, 2022
1 parent 59b75ee commit 6bd9c7f
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 10 deletions.
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 @@
## 1.0.11

* Replaces mentions of the deprecated `GoRouteData.buildPage` with `GoRouteData.buildPageWithState`.

## 1.0.10

* Adds a lint ignore for deprecated member in the example.
Expand Down
11 changes: 5 additions & 6 deletions packages/go_router_builder/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -279,15 +279,14 @@ of the page and the `restorationId` of the page.

If you'd like to change how the page is created, e.g. to use a different page
type, pass non-default parameters when creating the page (like a custom key) or
access the `GoRouteState` object, you can override the `buildPage` method of the
base class instead of the `build` method:
access the `GoRouteState` object, you can override the `buildPageWithState`
method of the base class instead of the `build` method:

```dart
class MyMaterialRouteWithKey extends GoRouteData {
static final _key = LocalKey('my-route-with-key');
@override
MaterialPage<void> buildPage(BuildContext context) =>
MaterialPage<void> buildPageWithState(BuildContext context, GoRouterState state) =>
MaterialPage<void>(
key: _key,
child: MyPage(),
Expand All @@ -297,12 +296,12 @@ class MyMaterialRouteWithKey extends GoRouteData {

### Custom transitions

Overriding the `buildPage` method is also useful for custom transitions:
Overriding the `buildPageWithState` method is also useful for custom transitions:

```dart
class FancyRoute extends GoRouteData {
@override
MaterialPage<void> buildPage(BuildContext context, GoRouterState state) =>
MaterialPage<void> buildPageWithState(BuildContext context, GoRouterState state) =>
CustomTransitionPage<void>(
key: state.pageKey,
child: FancyPage(),
Expand Down
4 changes: 2 additions & 2 deletions packages/go_router_builder/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,13 @@ class PersonDetailsRoute extends GoRouteData {
final int? $extra;

@override
// ignore: deprecated_member_use_from_same_package
Page<void> buildPage(BuildContext context) {
Page<void> buildPageWithState(BuildContext context, GoRouterState state) {
final Family family = familyById(fid);
final Person person = family.person(pid);

return MaterialPage<Object>(
fullscreenDialog: true,
key: state.pageKey,
child: PersonDetailsPage(
family: family,
person: person,
Expand Down
2 changes: 1 addition & 1 deletion packages/go_router_builder/example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ environment:
dependencies:
flutter:
sdk: flutter
go_router: ^4.0.0
go_router: ^4.4.1
provider: ^6.0.0

dev_dependencies:
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: 1.0.10
version: 1.0.11
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

0 comments on commit 6bd9c7f

Please sign in to comment.