createUser method

Future<UserRecord> createUser({
  1. bool? disabled,
  2. String? displayName,
  3. String? email,
  4. bool? emailVerified,
  5. String? password,
  6. String? phoneNumber,
  7. String? photoUrl,
  8. String? uid,
})

Creates a new user.

Implementation

Future<UserRecord> createUser({
  bool? disabled,
  String? displayName,
  String? email,
  bool? emailVerified,
  String? password,
  String? phoneNumber,
  String? photoUrl,
  String? uid,
}) async {
  try {
    uid = await _authRequestHandler.createNewAccount(CreateEditAccountRequest(
        disabled: disabled,
        displayName: displayName,
        email: email,
        emailVerified: emailVerified,
        password: password,
        phoneNumber: phoneNumber,
        photoUrl: photoUrl,
        uid: uid));
    // Return the corresponding user record.
    return await getUser(uid);
  } on FirebaseException catch (error) {
    if (error.code == 'auth/user-not-found') {
      // Something must have happened after creating the user and then retrieving it.
      throw FirebaseAuthError.internalError(
          'Unable to create the user record provided.');
    }
    rethrow;
  }
}