Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Michael Goderbauer <goderbauer@google.com>
  • Loading branch information
chunhtai and goderbauer authored Nov 3, 2023
1 parent 3b29ea6 commit 2ede2cc
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions packages/go_router/doc/navigation.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,11 @@ and retrieve the data from GoRouterState
final String extraString = GoRouterState.of(context).extra! as String;
```

The extra will go through serialization when it is stored in browser.
If you plan to use complex data as extra, consider also provide a codec
The extra data will go through serialization when it is stored in the browser.
If you plan to use complex data as extra, consider also providing a codec
to GoRouter so that it won't get dropped during serialization.

For an example on how to write use complex extra with codec, see
For an example on how to use complex data in extra with a codec, see
[extra_codec.dart](https://github.com/flutter/packages/blob/main/packages/go_router/example/lib/extra_codec.dart).


Expand Down
2 changes: 1 addition & 1 deletion packages/go_router/example/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ An example to demonstrate how to handle exception in go_router.
## [Extra Codec](https://github.com/flutter/packages/blob/main/packages/go_router/example/lib/extra_codec.dart)
`flutter run lib/extra_codec.dart`

An example to demonstrate how use complex object as extra.
An example to demonstrate how to use a complex object as extra.

## [Books app](https://github.com/flutter/packages/blob/main/packages/go_router/example/lib/books)
`flutter run lib/books/main.dart`
Expand Down
14 changes: 7 additions & 7 deletions packages/go_router/example/lib/extra_codec.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';

/// This sample app demonstrates how to provide an extra codec for complex extra.
/// This sample app demonstrates how to provide a codec for complex extra data.
void main() => runApp(const MyApp());

/// The route configuration.
/// The router configuration.
final GoRouter _router = GoRouter(
routes: <RouteBase>[
GoRoute(
Expand All @@ -35,9 +35,9 @@ class MyApp extends StatelessWidget {
}
}

/// The home screen
/// The home screen.
class HomeScreen extends StatelessWidget {
/// Constructs a [HomeScreen]
/// Constructs a [HomeScreen].
const HomeScreen({super.key});

@override
Expand All @@ -49,8 +49,8 @@ class HomeScreen extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
const Text(
'If running in web, use browser backward and forward button to test extra codec after setting extra several times'),
Text('extra for this page is: ${GoRouterState.of(context).extra}'),
'If running in web, use the browser's backward and forward button to test extra codec after setting extra several times.'),
Text('The extra for this page is: ${GoRouterState.of(context).extra}'),
ElevatedButton(
onPressed: () => context.go('/', extra: ComplexData1('data')),
child: const Text('Set extra to ComplexData1'),
Expand Down Expand Up @@ -92,7 +92,7 @@ class ComplexData2 {
/// A codec that can serialize both [ComplexData1] and [ComplexData2].
class MyExtraCodec extends Codec<Object?, Object?> {
/// Create a codec
/// Create a codec.
const MyExtraCodec();
@override
Converter<Object?, Object?> get decoder => const _MyExtraDecoder();
Expand Down

0 comments on commit 2ede2cc

Please sign in to comment.