我想获取当前已登录用户的电子邮件,但似乎找不到解决方法。
我认为它应该类似于:
FirebaseAuth.instance.currentUser().getEmail(); //The .getEmail() part is made up
最佳答案
假设您正在使用Firebase Auth软件包:
final FirebaseAuth _auth = FirebaseAuth.instance;
Future<FirebaseUser> _handleSignIn() async {
GoogleSignInAccount googleUser = await _googleSignIn.signIn();
GoogleSignInAuthentication googleAuth = await googleUser.authentication;
FirebaseUser user = await _auth.signInWithGoogle(
accessToken: googleAuth.accessToken,
idToken: googleAuth.idToken, );
// get email here
print("signed in " + user.email);
return user; }
并处理登录:
_handleSignIn() .then((FirebaseUser user) => print(user)) .catchError((e) => print(e));
关于firebase - 如何获取当前用户的电子邮件地址FirebaseAuth/Flutter,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/51191832/