Flutter Phone authentication error original example
1,614
It looks like that sample is outdated , you can omit AuthCredential
and GoogleAuthProvider
.
Future<String> _testSignInWithGoogle() async {
final GoogleSignInAccount googleUser = await _googleSignIn.signIn();
final GoogleSignInAuthentication googleAuth =
await googleUser.authentication;
final FirebaseUser user =
await FirebaseAuth.instance.signInWithGoogle(
accessToken: googleAuth.accessToken,
idToken: googleAuth.idToken,
);
assert(user.email != null);
assert(user.displayName != null);
assert(!user.isAnonymous);
assert(await user.getIdToken() != null);
final FirebaseUser currentUser = await _auth.currentUser();
assert(user.uid == currentUser.uid);
return 'signInWithGoogle succeeded: $user';
}
Author by
mreig
Updated on December 08, 2022Comments
-
mreig over 1 year
Dears,
I am developing this example (the original) of phone authentication: https://github.com/flutter/plugins/tree/master/packages/firebase_auth/example
Of course, I added the .json and correct dependencies (I think, because other complements of firebase works fine).
But, I get this part of code:
Future<String> _testSignInWithGoogle() async { final GoogleSignInAccount googleUser = await _googleSignIn.signIn(); final GoogleSignInAuthentication googleAuth = await googleUser.authentication; final AuthCredential credential = GoogleAuthProvider.getCredential( accessToken: googleAuth.accessToken, idToken: googleAuth.idToken, ); final FirebaseUser user = await _auth.signInWithCredential(credential); assert(user.email != null); assert(user.displayName != null); assert(!user.isAnonymous); assert(await user.getIdToken() != null); final FirebaseUser currentUser = await _auth.currentUser(); assert(user.uid == currentUser.uid); return 'signInWithGoogle succeeded: $user'; }
I have theses errors:
- Undefined AuthCredential
- Undefined name GoogleAuthProvider
- The method signInWithCredential is not defined for class FirebaseAuth
Can you help me please? I don't understand these error if it is the original example.
Thanks!!