Update firebase auth readme. (#192)
handle sign-in with a future?
diff --git a/packages/firebase_auth/README.md b/packages/firebase_auth/README.md
index 2eb9471..c5e334d 100755
--- a/packages/firebase_auth/README.md
+++ b/packages/firebase_auth/README.md
@@ -59,21 +59,26 @@
You can now use the Firebase `_auth` to authenticate in your Dart code, e.g.
```
-Future<Null> _handleSignIn() async {
- try {
- GoogleSignInAccount googleUser = await _googleSignIn.signIn();
- GoogleSignInAuthentication googleAuth = await googleUser.authentication;
- FirebaseUser user = await _auth.signInWithGoogle(
- accessToken: googleAuth.accessToken,
- idToken: googleAuth.idToken,
- );
- print("signed in" + user.displayName);
- } catch (error) {
- print(error);
- }
+Future<FirebaseUser> _handleSignIn() async {
+ GoogleSignInAccount googleUser = await _googleSignIn.signIn();
+ GoogleSignInAuthentication googleAuth = await googleUser.authentication;
+ FirebaseUser user = await _auth.signInWithGoogle(
+ accessToken: googleAuth.accessToken,
+ idToken: googleAuth.idToken,
+ );
+ print("signed in " + user.displayName);
+ return user;
}
```
+Then from the sign in button onPress,
+call the `_handleSignIn` method using a future callback for both the `FirebaseUser` and possible exception.
+```
+_handleSignIn()
+ .then((FirebaseUser user) => print(user))
+ .catchError((e) => print(e));
+```
+
## Example
See the [example application](https://github.com/flutter/plugins/tree/master/packages/firebase_auth/example) source