Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

Commit 195e922

Browse files
Paolo Rotologoderbauer
authored andcommitted
Fix incomplete README for FirebaseAuth (#694)
1 parent 49c1a2c commit 195e922

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

packages/firebase_auth/README.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ To use the firebase_auth plugin, follow the [plugin installation instructions](h
2020
Enable the Google services by configuring the Gradle scripts as such.
2121

2222
1. Add the classpath to the `[project]/android/build.gradle` file.
23-
```
23+
```gradle
2424
dependencies {
2525
// Example existing classpath
2626
classpath 'com.android.tools.build:gradle:3.1.2'
@@ -30,7 +30,7 @@ dependencies {
3030
```
3131

3232
2. Add the apply plugin to the `[project]/android/app/build.gradle` file.
33-
```
33+
```gradle
3434
// ADD THIS AT THE BOTTOM
3535
apply plugin: 'com.google.gms.google-services'
3636
```
@@ -48,17 +48,18 @@ Otherwise you will not be able to authenticate.
4848
### Use the plugin
4949

5050
Add the following imports to your Dart code:
51-
```
51+
```dart
5252
import 'package:firebase_auth/firebase_auth.dart';
5353
```
5454

55-
Initialize `FirebaseAuth`:
56-
```
55+
Initialize `GoogleSignIn` and `FirebaseAuth`:
56+
```dart
57+
final GoogleSignIn _googleSignIn = GoogleSignIn();
5758
final FirebaseAuth _auth = FirebaseAuth.instance;
5859
```
5960

6061
You can now use the Firebase `_auth` to authenticate in your Dart code, e.g.
61-
```
62+
```dart
6263
Future<FirebaseUser> _handleSignIn() async {
6364
GoogleSignInAccount googleUser = await _googleSignIn.signIn();
6465
GoogleSignInAuthentication googleAuth = await googleUser.authentication;
@@ -73,7 +74,7 @@ Future<FirebaseUser> _handleSignIn() async {
7374

7475
Then from the sign in button onPress, call the `_handleSignIn` method using a future
7576
callback for both the `FirebaseUser` and possible exception.
76-
```
77+
```dart
7778
_handleSignIn()
7879
.then((FirebaseUser user) => print(user))
7980
.catchError((e) => print(e));

0 commit comments

Comments
 (0)