mirror of
https://github.com/nisrulz/flutter-examples.git
synced 2025-11-09 13:09:03 +00:00
signInWithGoogle missing - FirebaseAuth
https://stackoverflow.com/questions/54508591/flutter-firebase-signinwithgoogle-method-not-found
This commit is contained in:
@@ -41,13 +41,15 @@ class AppState extends State<App> {
|
|||||||
FirebaseAuth _auth = FirebaseAuth.instance;
|
FirebaseAuth _auth = FirebaseAuth.instance;
|
||||||
try {
|
try {
|
||||||
googleSignIn = GoogleSignIn();
|
googleSignIn = GoogleSignIn();
|
||||||
GoogleSignInAccount googleSignInAccount = await googleSignIn.signIn();
|
GoogleSignInAccount googleUser = await googleSignIn.signIn();
|
||||||
GoogleSignInAuthentication gauth =
|
final GoogleSignInAuthentication googleAuth =
|
||||||
await googleSignInAccount.authentication;
|
await googleUser.authentication;
|
||||||
FirebaseUser user = await _auth.signInWithGoogle(
|
final AuthCredential credential = GoogleAuthProvider.getCredential(
|
||||||
accessToken: gauth.accessToken,
|
accessToken: googleAuth.accessToken,
|
||||||
idToken: gauth.idToken,
|
idToken: googleAuth.idToken,
|
||||||
);
|
);
|
||||||
|
final AuthResult authRes = await _auth.signInWithCredential(credential);
|
||||||
|
final FirebaseUser user = authRes.user;
|
||||||
|
|
||||||
setState(() {
|
setState(() {
|
||||||
_username = user.displayName;
|
_username = user.displayName;
|
||||||
|
|||||||
Reference in New Issue
Block a user