Error while doing Firebase google sign_in

て烟熏妆下的殇ゞ 提交于 2019-12-24 18:27:28

问题


I have implemented Google sign-in option in my project for users to sign in. The app is launching properly and I'm able to click on the google sign in, it is also displaying the google accounts available in my mobile but when I click on any account it is not moving to another page and throwing this error.

Here's my code:

final FirebaseAuth _firebaseAuth = FirebaseAuth.instance;
final GoogleSignIn _googleSignIn = new GoogleSignIn();

Future<FirebaseUser> _signIn(BuildContext context) async {

  Scaffold.of(context).showSnackBar(new SnackBar(
    content: new Text('Sign in'),
  ));

  final GoogleSignInAccount googleUser = await _googleSignIn.signIn();
  final GoogleSignInAuthentication googleAuth = await googleUser.authentication;

  final AuthCredential credential = GoogleAuthProvider.getCredential(
    accessToken: googleAuth.accessToken,
    idToken: googleAuth.idToken,
  );

  FirebaseUser userDetails = (await _firebaseAuth.signInWithCredential(credential)).user;
  ProviderDetails providerInfo = new ProviderDetails(userDetails.providerId);

  List<ProviderDetails> providerData = new List<ProviderDetails>();
  providerData.add(providerInfo);

  UserDetails details = new UserDetails(
    userDetails.providerId,
    userDetails.displayName,
    userDetails.photoUrl,
    userDetails.email,
    providerData,
  );
  Navigator.push(
    context,
    new MaterialPageRoute(
      builder: (context) => new Profile(detailsUser: details),
    ),
  );
  return userDetails;
}

Error:

W/ActivityThread(17894): handleWindowVisibility: no activity for token android.os.BinderProxy@19a997e
I/flutter (17894): PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null)
W/ActivityThread(17894): handleWindowVisibility: no activity for token android.os.BinderProxy@294d2d5
I/flutter (17894): PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null)
D/FlutterView(17894): Detaching from a FlutterEngine: io.flutter.embedding.engine.FlutterEngine@a62a191

this is my profile page code please do check

Code: class Profile extends StatelessWidget { final UserDetails detailsUser;

Profile({Key key, @required this.detailsUser}) : super(key: key);

@override Widget build(BuildContext context) { final GoogleSignIn _gSignIn = GoogleSignIn();

return  Scaffold(
    appBar:  AppBar(
      title:  Text(detailsUser.userName),
      automaticallyImplyLeading: false,
      actions: <Widget>[
        IconButton(
          icon: Icon(
            FontAwesomeIcons.signOutAlt,
            size: 20.0,
            color: Colors.white,
          ),
          onPressed: (){
            _gSignIn.signOut();
            print('Signed out');
            Navigator.pop(context);

          },
        ),
      ],
    ),
    body:Center(child: Column(
      mainAxisAlignment: MainAxisAlignment.center,
      children: <Widget>[
        CircleAvatar(
          backgroundImage:NetworkImage(detailsUser.photoUrl),
          radius: 50.0,
        ),
        SizedBox(height:10.0),
        Text(
          "Name : " + detailsUser.userName,
          style:  TextStyle(fontWeight: FontWeight.bold, color: Colors.black,fontSize: 20.0),
        ),
        SizedBox(height:10.0),
        Text(
          "Email : " + detailsUser.userEmail,
          style:  TextStyle(fontWeight: FontWeight.bold, color: Colors.black,fontSize: 20.0),
        ),
        SizedBox(height:10.0),
        Text(
          "Provider : " + detailsUser.providerDetails,
          style:  TextStyle(fontWeight: FontWeight.bold, color: Colors.black,fontSize: 20.0),
        ),

来源:https://stackoverflow.com/questions/59455961/error-while-doing-firebase-google-sign-in

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!