


# signUpWithEmailPassword method




    *[<Null safety>](https://dart.dev/null-safety)*




[FutureOr](https://api.flutter.dev/flutter/dart-async/FutureOr-class.html)&lt;void> signUpWithEmailPassword
()





<p>Creates a new user with the provided <code>email</code> and <code>password</code>.</p>
<p>Returns the newly created user's unique identifier.</p>
<p>Throws a SignUpWithEmailAndPasswordFailureInterface if
an exception occurs.</p>



## Implementation

```dart
FutureOr<void> signUpWithEmailPassword() async {
  if (!state.status.isValidated) {
    return;
  }

  final form = formRepository.accessForm(formName);
  emit(SignUpState(form: form, status: FormStatus.submissionInProgress));

  final email = form.valueOf<String?>(AuthFormField.email);
  final password = form.valueOf<String?>(AuthFormField.password);

  if (email.isNullOrEmpty || password.isNullOrEmpty) {
    emit(
      SignUpState(
        form: form,
        errorMessage: 'An error occured while retrieving data from the form.',
        status: FormStatus.submissionFailure,
      ),
    );
  }

  return CustomRoutine<Account, Data?>(
    routine: () => authenticationRepository.signUpWithEmailAndPassword(
      email: email!,
      password: password!,
    ),
    attachedLogic: (routineResult) => onSignUpWithEmailAndPassword(
      routineResult,
      form,
    ),
    onError: (error) {
      emit(
        SignUpState(
          form: form,
          errorMessage: error.message,
          status: FormStatus.submissionFailure,
        ),
      );
      addError(error);
    },
    onSuccess: (account, data) {
      authenticationRepository.addSession(
        SessionWrapper(
          event: SignedUpEvent(account: account),
          session: Session<Data>(
            account: account,
            data: data,
          ),
        ),
      );
      emit(
        SignUpState(
          form: form,
          status: FormStatus.submissionSuccess,
        ),
      );
    },
  ).call();
}
```







