[firebase_auth ^0.15.4] <Multiple accounts per email address>

In firebase authentication Allow creation of multiple accounts with the same email address
GoogleSignInAccount googleUser = await googleSignIn.signIn();
print(googleUser.authentication);
GoogleSignInAuthentication googleAuth = await googleUser.authentication;
print(googleAuth.idToken);
final AuthCredential credential = GoogleAuthProvider.getCredential(
accessToken: googleAuth.accessToken,
idToken: googleAuth.idToken,
);
print(credential);
FirebaseUser firebaseUser =
(await firebaseAuth.signInWithCredential(credential)).user;
print("=====firebaseUser");
print(firebaseUser);
print(firebaseUser.email);
After logging in, getting the email(even others functions like displayName, photoUrl) using the FireBaseUser instance(firebase.email) returns null.
here is the output/print:

But choosing back the Prevent creation of multiple accounts with the same email address in authentication advance settings:

No errors but returning the expected email address.
PS. that email address was used in different provider(like facebook login)
Hi @kingdg25
can you please provide your flutter doctor -v ,
your flutter run --verbose
and your pubspec.yaml
Thank you
@kingdg25 May be a bug, try to get email by
final email = firebaseUser.email ?? firebaseUser.providerData.firstOrNullWhere((e) => e.email != null)?.email;
firstOrNullWhere from dartx: https://pub.dev/packages/dartx or write by your self.
@kingdg25 May be a bug, try to get email by
final email = firebaseUser.email ?? firebaseUser.providerData.firstOrNullWhere((e) => e.email != null)?.email;firstOrNullWhere from
dartx: https://pub.dev/packages/dartx or write by your self.
Thanks for this solution.
Hi @kingdg25
I have tested this using the WIP roadmap version as per below, and can confirm that the information required can be found in providerData. It looks like the implementation is the same for the version you are using as per your comment above.
final GoogleSignInAccount googleUser = await GoogleSignIn().signIn();
GoogleSignInAuthentication googleAuth = await googleUser.authentication;
final AuthCredential credential = GoogleAuthProvider.credential(
accessToken: googleAuth.accessToken,
idToken: googleAuth.idToken,
);
final UserCredential firebaseUser = await FirebaseAuth.instance.signInWithCredential(credential);
print(firebaseUser.user);
User(displayName: Greg, email: null, emailVerified: false, isAnonymous: false, metadata: UserMetadata(creationTime: 2020-07-14 12:06:24.661, lastSignInTime: 2020-07-14 12:54:50.509), phoneNumber: null, photoURL: https://lh3.googleusercontent.com/a-/*****, providerData, [UserInfo(displayName: Greg, email: g****@****.com, phoneNumber: null, providerId: google.com, uid: ******)], refreshToken: , tenantId: null, uid: *******)