进行Firebase谷歌登录时出错

问题描述 投票:0回答:1

我已经在我的项目中实现了Google登录选项,以便用户登录。该应用正常启动,我可以点击google登录,它还会显示我的移动设备上可用的Google帐户,但是当我单击任何没有移动到另一个页面并引发此错误的帐户。

这是我的代码:

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;
}

错误:

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

这是我的个人资料页代码,请检查

代码:类Profile扩展了StatelessWidget {最终的UserDetails detailsUser;

个人资料({Key key,@required this.detailsUser}):super(key:key);

@ override小部件build(BuildContext context){最终的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),
        ),
firebase flutter dart google-signin
1个回答
0
投票

ApiException:10

© www.soinside.com 2019 - 2024. All rights reserved.