submitForm method

Future<void> submitForm()

Implementation

Future<void> submitForm() async {
  setState(() {
    forceDisplayFieldsError = true;
  });

  if (model.isComplete()) {
    final bool enabledSubmitFormWrapper = enableSubmitFormWrapper ??
        AFTheme.of(context).enableSubmitFormWrapper;

    try {
      if (enabledSubmitFormWrapper && enableFinalAction) {
        await theme.submitFormWrapper(
          context: context,
          future: submit(model),
        );
      } else {
        await submit(model);
      }
    } on SubmitException catch (exception) {
      handleErrorOnSubmit?.call(exception.errorMessage);
    }
  } else {
    handleErrorOnSubmit?.call(model.getFirstError()!);
  }
}