Skip to content

Commit 9434012

Browse files
doc: Use GoRouter state.uri.queryParameters (#1876)
Relates to flutter/packages#4881 and flutter/flutter#133773 This updates the documentation to the latest `go_router` version by using `state.uri.queryParameters` instead of `state.queryParameters`. ## Pre-launch Checklist - [x] I read the [Effective Dart: Style] _recently_, and have followed its advice. - [x] I signed the [CLA]. - [x] I updated/added relevant documentation (doc comments with `///`). - [ ] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-devrel channel on [Discord]. <!-- Links --> [Effective Dart: Style]: https://dart.dev/guides/language/effective-dart/style [CLA]: https://cla.developers.google.com/ [Discord]: https://github.com/flutter/flutter/wiki/Chat
1 parent ae3e803 commit 9434012

File tree

1 file changed

+23
-23
lines changed

1 file changed

+23
-23
lines changed

firebase-get-to-know-flutter/steps/index.lab.md

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ The configuration command guides you through the following processes:
254254

255255
Flutter on macOS builds fully sandboxed apps. As this app integrates with the network to communicate with the Firebase servers, you need to configure your app with network client privileges.
256256

257-
#### [macos/Runner/DebugProfile.entitlements](https://github.com/flutter/codelabs/blob/master/firebase-get-to-know-flutter/step_04/macos/Runner/DebugProfile.entitlements)
257+
#### [macos/Runner/DebugProfile.entitlements](https://github.com/flutter/codelabs/blob/main/firebase-get-to-know-flutter/step_04/macos/Runner/DebugProfile.entitlements)
258258
```xml
259259
<?xml version="1.0" encoding="UTF-8"?>
260260
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
@@ -273,7 +273,7 @@ Flutter on macOS builds fully sandboxed apps. As this app integrates with the ne
273273
</plist>
274274
```
275275

276-
#### [macos/Runner/Release.entitlements](https://github.com/flutter/codelabs/blob/master/firebase-get-to-know-flutter/step_04/macos/Runner/Release.entitlements)
276+
#### [macos/Runner/Release.entitlements](https://github.com/flutter/codelabs/blob/main/firebase-get-to-know-flutter/step_04/macos/Runner/Release.entitlements)
277277
```xml
278278
<?xml version="1.0" encoding="UTF-8"?>
279279
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
@@ -303,7 +303,7 @@ Use the [`provider` package](https://pub.dev/packages/provider) to make a centr
303303

304304
1. Create a new file named `app_state.dart` with the following content:
305305

306-
#### [lib/app_state.dart](https://github.com/flutter/codelabs/blob/master/firebase-get-to-know-flutter/step_05/lib/app_state.dart#L1)
306+
#### [lib/app_state.dart](https://github.com/flutter/codelabs/blob/main/firebase-get-to-know-flutter/step_05/lib/app_state.dart#L1)
307307

308308
```dart
309309
import 'package:firebase_auth/firebase_auth.dart'
@@ -352,7 +352,7 @@ You only use a provider to communicate the state of a user's login status to the
352352

353353
1. Modify the imports at the top of the `lib/main.dart` file:
354354

355-
#### [lib/main.dart](https://github.com/flutter/codelabs/blob/master/firebase-get-to-know-flutter/step_05/lib/main.dart#L1)
355+
#### [lib/main.dart](https://github.com/flutter/codelabs/blob/main/firebase-get-to-know-flutter/step_05/lib/main.dart#L1)
356356

357357
```dart
358358
import 'package:firebase_ui_auth/firebase_ui_auth.dart'; // new
@@ -367,7 +367,7 @@ import 'home_page.dart';
367367

368368
2. Connect the app state with the app initialization and then add the authentication flow to `HomePage`:
369369

370-
#### [lib/main.dart](https://github.com/flutter/codelabs/blob/master/firebase-get-to-know-flutter/step_05/lib/main.dart#L14)
370+
#### [lib/main.dart](https://github.com/flutter/codelabs/blob/main/firebase-get-to-know-flutter/step_05/lib/main.dart#L14)
371371

372372
```dart
373373
void main() {
@@ -386,7 +386,7 @@ The modification to the `main()` function makes the provider package responsible
386386

387387
3. Update your app to handle navigation to different screens that FirebaseUI provides for you, by creating a `GoRouter` configuration:
388388

389-
#### [lib/main.dart](https://github.com/flutter/codelabs/blob/master/firebase-get-to-know-flutter/step_05/lib/main.dart#L23)
389+
#### [lib/main.dart](https://github.com/flutter/codelabs/blob/main/firebase-get-to-know-flutter/step_05/lib/main.dart#L23)
390390

391391
```dart
392392
// Add GoRouter configuration outside the App class
@@ -438,7 +438,7 @@ final _router = GoRouter(
438438
GoRoute(
439439
path: 'forgot-password',
440440
builder: (context, state) {
441-
final arguments = state.queryParameters;
441+
final arguments = state.uri.queryParameters;
442442
return ForgotPasswordScreen(
443443
email: arguments['email'],
444444
headerMaxExtent: 200,
@@ -495,7 +495,7 @@ Each screen has a different type of action associated with it based on the new s
495495

496496
4. In the `HomePage` class's build method, integrate the app state with the `AuthFunc` widget:
497497

498-
#### [lib/home_page.dart](https://github.com/flutter/codelabs/blob/master/firebase-get-to-know-flutter/step_05/lib/home_page.dart#L14)
498+
#### [lib/home_page.dart](https://github.com/flutter/codelabs/blob/main/firebase-get-to-know-flutter/step_05/lib/home_page.dart#L14)
499499

500500
```dart
501501
import 'package:firebase_auth/firebase_auth.dart' // new
@@ -596,7 +596,7 @@ In this section, you add the functionality for users to write messages to the da
596596

597597
1. Create a new file named `guest_book.dart`, add a `GuestBook` stateful widget to construct the UI elements of a message field and a send button:
598598

599-
#### [lib/guest_book.dart](https://github.com/flutter/codelabs/blob/master/firebase-get-to-know-flutter/step_06/lib/guest_book.dart)
599+
#### [lib/guest_book.dart](https://github.com/flutter/codelabs/blob/main/firebase-get-to-know-flutter/step_06/lib/guest_book.dart)
600600

601601
```dart
602602
import 'dart:async';
@@ -696,7 +696,7 @@ Note that `FirebaseAuth.instance.currentUser.uid` is a reference to the autogene
696696

697697
* In the `lib/app_state.dart` file, add the `addMessageToGuestBook` method. You connect this capability with the user interface in the next step.
698698

699-
#### [lib/app_state.dart](https://github.com/flutter/codelabs/blob/master/firebase-get-to-know-flutter/step_06/lib/app_state.dart#L41)
699+
#### [lib/app_state.dart](https://github.com/flutter/codelabs/blob/main/firebase-get-to-know-flutter/step_06/lib/app_state.dart#L41)
700700

701701
```dart
702702
import 'package:cloud_firestore/cloud_firestore.dart'; // new
@@ -737,7 +737,7 @@ You have a UI where the user can enter the text they want to add to the Guest Bo
737737

738738
* In the `lib/home_page.dart` file, make the following change to the `HomePage` widget:
739739

740-
#### [lib/home_page.dart](https://github.com/flutter/codelabs/blob/master/firebase-get-to-know-flutter/step_06/lib/home_page.dart#L15)
740+
#### [lib/home_page.dart](https://github.com/flutter/codelabs/blob/main/firebase-get-to-know-flutter/step_06/lib/home_page.dart#L15)
741741

742742
```dart
743743
import 'package:firebase_auth/firebase_auth.dart'
@@ -830,7 +830,7 @@ To display messages, you need to add listeners that trigger when data changes an
830830

831831
1. Create a new file `guest_book_message.dart`, add the following class to expose a structured view of the data that you store in Firestore.
832832

833-
#### [lib/guest_book_message.dart](https://github.com/flutter/codelabs/blob/master/firebase-get-to-know-flutter/step_07/lib/guest_book_message.dart)
833+
#### [lib/guest_book_message.dart](https://github.com/flutter/codelabs/blob/main/firebase-get-to-know-flutter/step_07/lib/guest_book_message.dart)
834834

835835
```dart
836836
class GuestBookMessage {
@@ -843,7 +843,7 @@ class GuestBookMessage {
843843

844844
2. In the `lib/app_state.dart` file, add the following imports:
845845

846-
#### [lib/app_state.dart](https://github.com/flutter/codelabs/blob/master/firebase-get-to-know-flutter/step_07/lib/app_state.dart#L1)
846+
#### [lib/app_state.dart](https://github.com/flutter/codelabs/blob/main/firebase-get-to-know-flutter/step_07/lib/app_state.dart#L1)
847847

848848
```dart
849849
import 'dart:async'; // new
@@ -861,7 +861,7 @@ import 'guest_book_message.dart'; // new
861861

862862
3. In section of `ApplicationState` where you define state and getters, add the following lines:
863863

864-
#### [lib/app_state.dart](https://github.com/flutter/codelabs/blob/master/firebase-get-to-know-flutter/step_07/lib/app_state.dart#L22)
864+
#### [lib/app_state.dart](https://github.com/flutter/codelabs/blob/main/firebase-get-to-know-flutter/step_07/lib/app_state.dart#L22)
865865

866866
```dart
867867
bool _loggedIn = false;
@@ -876,7 +876,7 @@ import 'guest_book_message.dart'; // new
876876

877877
4. In the initialization section of `ApplicationState`, add the following lines to subscribe to a query over the document collection when a user logs in and unsubscribe when they log out:
878878

879-
#### [lib/app_state.dart](https://github.com/flutter/codelabs/blob/master/firebase-get-to-know-flutter/step_07/lib/app_state.dart#L29)
879+
#### [lib/app_state.dart](https://github.com/flutter/codelabs/blob/main/firebase-get-to-know-flutter/step_07/lib/app_state.dart#L29)
880880

881881
```dart
882882
Future<void> init() async {
@@ -930,7 +930,7 @@ import 'guest_book_message.dart';
930930

931931
6. In the `GuestBook` widget, add a list of messages as part of the configuration to connect this changing state to the user interface:
932932

933-
#### [lib/guest_book.dart](https://github.com/flutter/codelabs/blob/master/firebase-get-to-know-flutter/step_07/lib/guest_book.dart#L12)
933+
#### [lib/guest_book.dart](https://github.com/flutter/codelabs/blob/main/firebase-get-to-know-flutter/step_07/lib/guest_book.dart#L12)
934934

935935
```dart
936936
class GuestBook extends StatefulWidget {
@@ -951,7 +951,7 @@ class GuestBook extends StatefulWidget {
951951

952952
7. In `_GuestBookState`, modify the `build` method as follows to expose this configuration:
953953

954-
#### [lib/guest_book.dart](https://github.com/flutter/codelabs/blob/master/firebase-get-to-know-flutter/step_07/lib/guest_book.dart#L26)
954+
#### [lib/guest_book.dart](https://github.com/flutter/codelabs/blob/main/firebase-get-to-know-flutter/step_07/lib/guest_book.dart#L26)
955955

956956
```dart
957957
class _GuestBookState extends State<GuestBook> {
@@ -1021,7 +1021,7 @@ You wrap the previous content of the `build()` method with a `Column` widget and
10211021

10221022
8. Update the body of `HomePage` to correctly construct `GuestBook` with the new `messages` parameter:
10231023

1024-
#### [lib/home_page.dart](https://github.com/flutter/codelabs/blob/master/firebase-get-to-know-flutter/step_07/lib/home_page.dart#L48)
1024+
#### [lib/home_page.dart](https://github.com/flutter/codelabs/blob/main/firebase-get-to-know-flutter/step_07/lib/home_page.dart#L48)
10251025

10261026
```dart
10271027
Consumer<ApplicationState>(
@@ -1140,7 +1140,7 @@ In this step, you get organized and let people know how many people are coming.
11401140
11411141
1. In the `lib/app_state.dart` file, add the following lines to the accessors section of the `ApplicationState` so that the UI code can interact with this state:
11421142
1143-
#### [lib/app_state.dart](https://github.com/flutter/codelabs/blob/master/firebase-get-to-know-flutter/step_09/lib/app_state.dart#L37)
1143+
#### [lib/app_state.dart](https://github.com/flutter/codelabs/blob/main/firebase-get-to-know-flutter/step_09/lib/app_state.dart#L37)
11441144
11451145
```dart
11461146
int _attendees = 0;
@@ -1163,7 +1163,7 @@ set attending(Attending attending) {
11631163
11641164
2. Update the `ApplicationState`'s `init()` method as follows:
11651165
1166-
#### [lib/app_state.dart](https://github.com/flutter/codelabs/blob/master/firebase-get-to-know-flutter/step_09/lib/app_state.dart#L80)
1166+
#### [lib/app_state.dart](https://github.com/flutter/codelabs/blob/main/firebase-get-to-know-flutter/step_09/lib/app_state.dart#L80)
11671167
11681168
```dart
11691169
Future<void> init() async {
@@ -1237,15 +1237,15 @@ This code adds an always-subscribed query to determine the number of attendees a
12371237
12381238
3. Add the following enumeration at the top of the `lib/app_state.dart` file.
12391239
1240-
#### [lib/app_state.dart](https://github.com/flutter/codelabs/blob/master/firebase-get-to-know-flutter/step_09/lib/app_state.dart#L5)
1240+
#### [lib/app_state.dart](https://github.com/flutter/codelabs/blob/main/firebase-get-to-know-flutter/step_09/lib/app_state.dart#L5)
12411241
12421242
```dart
12431243
enum Attending { yes, no, unknown }
12441244
```
12451245
12461246
4. Create a new file `yes_no_selection.dart`, define a new widget that acts like radio buttons:
12471247
1248-
#### [lib/yes_no_selection.dart](https://github.com/flutter/codelabs/blob/master/firebase-get-to-know-flutter/step_09/lib/yes_no_selection.dart)
1248+
#### [lib/yes_no_selection.dart](https://github.com/flutter/codelabs/blob/main/firebase-get-to-know-flutter/step_09/lib/yes_no_selection.dart)
12491249
12501250
```dart
12511251
import 'package:flutter/material.dart';
@@ -1322,7 +1322,7 @@ It starts in an indeterminate state with neither **Yes** nor **No** selected. On
13221322
13231323
5. Update `HomePage`'s `build()` method to take advantage of `YesNoSelection`, enable a logged-in user to nominate whether they're attending, and display the number of attendees for the event:
13241324
1325-
#### [lib/home_page.dart](https://github.com/flutter/codelabs/blob/master/firebase-get-to-know-flutter/step_09/lib/home_page.dart#L56)
1325+
#### [lib/home_page.dart](https://github.com/flutter/codelabs/blob/main/firebase-get-to-know-flutter/step_09/lib/home_page.dart#L56)
13261326
13271327
```dart
13281328
Consumer<ApplicationState>(

0 commit comments

Comments
 (0)