createUser method

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

Creates a new user.

Implementation

Future<UserRecord> createUser({
  bool? disabled,
  String? displayName,
  String? email,
  bool? emailVerified,
  String? password,
  String? phoneNumber,
  Uri? photoUrl,
  String? uid,
  List<CreateMultiFactorInfoRequest>? multiFactorEnrolledFactors,
}) async {
  try {
    uid = await _authRequestHandler.createNewAccount(
      disabled: disabled,
      displayName: displayName,
      email: email,
      emailVerified: emailVerified,
      password: password,
      phoneNumber: phoneNumber,
      photoUrl: photoUrl?.toString(),
      uid: uid,
      multiFactorEnrolledFactors: multiFactorEnrolledFactors,
    );
    // 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;
  }
}