Firebase Email Verification does not work, I well receive the mail, but emailVerified return false

Viewed 87

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);
  }
1 Answers

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);
  }
Related