2

I well receive the mail from Firebase for the verification of my mail. I well click on the link received, but it is always returning false in my code for .emailVerified. What 's wrong ?

void verifyEmail() async {
    print(FirebaseAuth.instance.currentUser!.email);
    await FirebaseAuth.instance.currentUser!.reload;
    bool emailVerified = await FirebaseAuth.instance.currentUser!.emailVerified;
    print(emailVerified);
  }
Chloé
  • 331
  • 1
  • 5
  • 14

1 Answers1

1

As what I have read about that issue, you have to reload your Firebase User after you had sent the verification email and get the user instance again.

void verifyEmail() async {
    print(FirebaseAuth.instance.currentUser!.email);
    await FirebaseAuth.instance.currentUser?.reload(); // <- Also add brackets here
    final user = FirebaseAuth.instance.currentUser;
    bool emailVerified = user.emailVerified;
    print(emailVerified);
  }
Marcel Dz
  • 2,321
  • 4
  • 14
  • 49
  • You actually have to reload the profile after the user has clicked the link in the email, which is typically not immediately after it's been sent. – Frank van Puffelen Jul 08 '22 at 14:13
  • Not working for me, I have finally resolved it with this solution, thx : https://stackoverflow.com/questions/57192651/flutter-how-to-listen-to-the-firebaseuser-is-email-verified-boolean/60471750#60471750 – Chloé Jul 09 '22 at 00:11