如何解决[错误:flutter/lib/ui/ui_start_state.cc(186)]未处理的异常



我收到关于[错误:flutter/lib/ui_dart_state.cc(186(]的错误未处理异常:异常:登录失败。有人知道怎么解决这个问题吗?提前感谢

这是我的代码:

Future<dynamic> loginWithGoogle() async {
try {
_authProvider = AuthProvider.Google;

GoogleSignInAccount user = await _googleSignIn.signIn();
GoogleSignInAuthentication googleSignInAuthentication =
await user.authentication;

loginWithMediaSocial(googleSignInAuthentication.accessToken)
.then((value) {
if (value['errorCode']== 500) {
String error = "Login failed.";
throw Exception (error);
}
});
} catch (e) {
print(e);
}
}

您是否遵循了firebase文档?我认为为了使用谷歌登录,你应该按照firebase文档中提到的步骤,在使用谷歌登录之前添加文件googleservices.json。

如果您无法使用身份验证,请尝试以下步骤。

以下解决方案适用于颤振项目:

Step 1: Generate SHA1 and SHA256 keys. 
Step 2: Add both the SHA1 and SHA256 to firebase. (in you app settings)
Step 3: Download google-services.json to android/app in your project folder.
Step 4: In your terminal run the command flutter clean .
Step 5: Run your flutter app.

有关更多信息,请访问:https://developers.google.com/android/guides/client-authhttps://firebase.google.com/docs/flutter/setup

最新更新