我知道这里也有同样的帖子,但似乎没有答案。我在GoogleSignIn下面有一条红线,有提到要将google_sign_in包版本从5.0.4降级到5.03,但这并没有帮助我摆脱这个错误。到目前为止,我的代码如下:
发布于 2021-06-12 00:33:15
GoogleSignIn().signIn() return GoogleSignInAccount?这意味着它可能是空的。另一方面,您的googleUser变量的类型为GoogleSignInAccount,这意味着它不能为空。您应该重构您的代码,使其看起来像这样:
Future<UserCredential?> signInWithGoogle() async {
final GoogleSignInAccount? googleUser = GoogleSignIn().signIn();
if (googleUser != null) {
// Rest of the code
...
}
}https://stackoverflow.com/questions/67939847
复制相似问题