registerWithEmail method

Future<void> registerWithEmail(
  1. String email,
  2. String password,
  3. String displayName
)

Implementation

Future<void> registerWithEmail(
    String email, String password, String displayName) async {
  _updateState(const AuthState.loading());
  try {
    verbose('Registering with email...');
    final _UserCredential credential = await _firebase
        .auth()
        .createUserWithEmailAndPassword(email, password)
        .toDart;

    if (credential.user != null) {
      await credential.user!
          .updateProfile(_ProfileUpdate(displayName: displayName))
          .toDart;
    }
  } catch (e) {
    error('Email registration failed: $e');
    _updateState(AuthState.withError(_parseFirebaseError(e)));
  }
}