signUp method

Future<void> signUp(
  1. User user,
  2. String password
)

Signs in the user with the given username and password

Implementation

Future<void> signUp(
  User user,
  String password,
) async {
  emit(state.startLoading(signUpLoading));

  try {
    user = setProfilePictureUrl(user);
    final verification = await provider.signUp(user, password);
    emit(state.copyWith(
      awaitingVerification: verification,
    ));
  } on UsernameExistsException catch (error, stackTrace) {
    emit(state.addMessage(
      Message.error(_localizations.userNameExists),
      error,
      stackTrace,
    ));
  } on SignUpException catch (error, stackTrace) {
    emit(state.addMessage(
      Message.error(
        _localizations.signUpError(error.message),
      ),
      error,
      stackTrace,
    ));
  } finally {
    emit(state.endLoading(signUpLoading));
  }
}