相关疑难解决方法(0)

未定义的类“FirebaseUser”

我是 Flutter 的新手。我有Firebase Auth/Google Auth 的问题FirebaseUser未定义代码:

FirebaseAuth _auth = FirebaseAuth.instance;
GoogleSignIn googleSignIn = GoogleSignIn();

Future<FirebaseUser> currentUser() async { // The Issue is here in the Future<>
  final GoogleSignInAccount account = await googleSignIn.signIn();
  final GoogleSignInAuthentication authentication =
      await account.authentication;

  final GoogleAuthCredential credential = GoogleAuthProvider.getCredential(
      idToken: authentication.idToken, accessToken: authentication.accessToken);

  final AuthResult authResult = await _auth.signInWithCredential(credential);
  final FirebaseUser user = authResult.user; // and here as I can't define this FirebaseUser object to return

  return user;
}
Run Code Online (Sandbox Code Playgroud)

pubspec.yml

dependencies:
  flutter:
    sdk: …
Run Code Online (Sandbox Code Playgroud)

google-authentication dart firebase firebase-authentication flutter

19
推荐指数
2
解决办法
2万
查看次数