How to get logged in user's email in Flutter using Firebase
I want to get the email of the logged in user in a Flutter app which uses Firebase for authentication.
I can get the current user by
final user = await _auth.currentUser();
But if I try this to get the mail
final mailID = await _auth.currentUser().email.toString();
I get the following error:
The getter 'email' isn't defined for the type 'Future<FirebaseUser>'.
Try importing the library that defines 'email', correcting the name to the name of an existing getter, or defining a getter or field named 'email'.
How to get the logged in user's email in this case?
Get the user before trying to get the email. code below
<FirebaseUser> user = await _auth.currentUser();
final mailID = user.email;