执行Firebase google登录时出错
我已经在我的项目中实现了谷歌登录选项,供用户登录。该应用程序正在正常启动,我可以点击谷歌登录,它还显示了我手机上可用的谷歌账户,但当我点击任何账户时,它不会移动到另一个页面并抛出此错误 这是我的密码:执行Firebase google登录时出错,firebase,flutter,dart,google-signin,Firebase,Flutter,Dart,Google Signin,我已经在我的项目中实现了谷歌登录选项,供用户登录。该应用程序正在正常启动,我可以点击谷歌登录,它还显示了我手机上可用的谷歌账户,但当我点击任何账户时,它不会移动到另一个页面并抛出此错误 这是我的密码: final FirebaseAuth _firebaseAuth = FirebaseAuth.instance; final GoogleSignIn _googleSignIn = new GoogleSignIn(); Future<FirebaseUser> _signIn(
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;
}
这是我的个人资料页面代码,请检查
代码:
类配置文件扩展了无状态小部件{
最终用户详细信息
Profile({Key-Key,@required this.detailsUser}):super(Key:Key)
@凌驾
小部件构建(构建上下文){
最终谷歌签名_gSignIn=谷歌签名()
返回脚手架(
appBar:appBar(
标题:文本(detailsUser.userName),
自动嵌入:false,
行动:[
图标按钮(
图标:图标(
FontAwesomeIcons.signOutAlt,
尺寸:20.0,
颜色:颜色,白色,
),
已按下:(){
_gSignIn.signOut();
打印(“已签出”);
Navigator.pop(上下文);
},
),
],
),
主体:中心(子项:列)(
mainAxisAlignment:mainAxisAlignment.center,
儿童:[
圆形(
背景图片:NetworkImage(detailsUser.photoUrl),
半径:50.0,
),
尺寸箱(高度:10.0),
正文(
“名称:”+detailsUser.userName,
样式:TextStyle(fontWeight:fontWeight.bold,颜色:Colors.black,fontSize:20.0),
),
尺寸箱(高度:10.0),
正文(
“电子邮件:”+detailsUser.userEmail,
样式:TextStyle(fontWeight:fontWeight.bold,颜色:Colors.black,fontSize:20.0),
),
尺寸箱(高度:10.0),
正文(
“提供者:”+detailsUser.providerDetails,
样式:TextStyle(fontWeight:fontWeight.bold,颜色:Colors.black,fontSize:20.0),
),
您是否创建了个人资料widgetYes我已创建iti已更新个人资料页面代码,请检查
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
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),
),