updateEmail method

Future<void> updateEmail(
  1. String newEmail
)

Updates the user's email address.

An email will be sent to the original email address (if it was set) that allows to revoke the email address change, in order to protect them from account hijacking.

Important: this is a security sensitive operation that requires the user to have recently signed in. If this requirement isn't met, ask the user to authenticate again and then call User.reauthenticateWithCredential.

A FirebaseAuthException maybe thrown with the following error code:

  • email-not-found: user doesn't exist

Implementation

Future<void> updateEmail(String newEmail) async {
  _assertSignedOut(_auth);

  try {
    await _auth._api.emailAndPasswordAccount
        .updateEmail(newEmail, _idToken, uid);
    await reload();
  } catch (e) {
    rethrow;
  }
}