


# updatePassword method




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




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





<p>Update or add <code>password</code>.</p>
<p>Throws a UpdatePasswordFailureInterface if
an exception occurs.</p>



## Implementation

```dart
FutureOr<void> updatePassword() async {
  if (state.status.isSubmissionInProgress) {
    return;
  }

  if (!state.status.isValidated) {
    return;
  }

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

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

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

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







