submit method

Future<bool> submit(
  1. FutureOr<void> onSubmit(
    1. Map<String, String> values
    ), {
  2. bool resetOnSuccess = false,
})

Validates, saves, and runs onSubmit with the current text values.

Sets submitting to true for the duration of onSubmit and guards against concurrent submissions. If resetOnSuccess is true, the form is reset after onSubmit completes successfully. Returns false if the form failed validation or a submission was already in progress.

Implementation

Future<bool> submit(
  FutureOr<void> Function(Map<String, String> values) onSubmit, {
  bool resetOnSuccess = false,
}) async {
  if (_submitting || !validateAndSave()) {
    return false;
  }

  _setSubmitting(true);
  try {
    await onSubmit(textValues());
    if (resetOnSuccess) {
      reset();
    }
    return true;
  } finally {
    _setSubmitting(false);
  }
}