Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
272 views
in Technique[技术] by (71.8m points)

firebase - Error signing In with google using firebaseAuthemtication

I am using the following code to sign in with Google using firebase authentication.

     Future<bool> signInWithGoogle(context) async {
            // Trigger the authentication flow
bool signedIn = true;
            final GoogleSignInAccount googleUser = await GoogleSignIn().signIn()
               .catchError((error){
                  //ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text(error)));
                  signedIn = false;
                });
            // Obtain the auth details from the request
            final GoogleSignInAuthentication googleAuth = await googleUser.authentication
    .catchError((onError)=> signedIn = false);
            // Create a new credential
            final GoogleAuthCredential credential = GoogleAuthProvider.credential(
              accessToken: googleAuth.accessToken,
              idToken: googleAuth.idToken,
            );
            // Once signed in, return the UserCredential
            UserCredential userCredential = await FirebaseAuth.instance.signInWithCredential(credential);
            firebaseUser = userCredential.user;
            return signedIn;
          }

Most of the time my code works fine but at times I get an error in the console which I am not sure of. I need help in resolving this error and understanding the root of this.

The error is as follows:

E/flutter (26892): [ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: type 'bool' is not a subtype of type 'FutureOr<GoogleSignInAccount>'
E/flutter (26892): #0      _FutureListener.handleError (dart:async/future_impl.dart:160:20)
E/flutter (26892): #1      Future._propagateToListeners.handleError (dart:async/future_impl.dart:708:47)
E/flutter (26892): #2      Future._propagateToListeners (dart:async/future_impl.dart:729:24)...
...
question from:https://stackoverflow.com/questions/66054677/error-signing-in-with-google-using-firebaseauthemtication

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...