createUserWithEmailAndPassword method

Future<UserCredential> createUserWithEmailAndPassword(
  1. {required String email,
  2. required String password}
)

Creates a new user with the provided email and password.

email The user's email address. password The user's password.

Registers the user and signs them in.

Returns a Future containing the UserCredential with the new user.

Throws FusabaseAuthException if email or password is invalid or registration fails.

Example:

UserCredential credential = await auth.createUserWithEmailAndPassword(
  email: 'user@example.com',
  password: 'password123'
);

Implementation

Future<UserCredential> createUserWithEmailAndPassword({
  required String email,
  required String password,
}) async {
  await _initFuture;
  if (email == "" || password == "") {
    throw AuthUtils.authErrorHandler(
      status: globals.ErrorMap[globals.ErrorCode.INVALID_ARGS] ?? 999,
      message: AuthErrorMessageTemplates.format(
        AuthErrorMessageTemplates.INVALID_PARAM,
        ['email or password'],
      ),
      authType: null,
      stackTrace: null,
    );
  }
  await _authHelper.registerUser(
    client: createClient(app),
    email: email,
    password: password,
    url: "",
  );

  return signInWithEmailAndPassword(email: email, password: password);
}