我是 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