submit<T> method
Checks if form is valid, then submits form by calling FormerForm.submit. (FormerForm is extended by your own form classes, so FormerForm.submit should contain your own implementations of how to submit the forms).
If form is invalid, FormInvalidException is thrown. The name of the invalid form is available as FormInvalidException.invalidForm.
form is automatically disabled until FormerForm.submit finishes. form will then be re-enabled.
Accepts generic parameter T
that should match the return value
of the submit method of your form. For example, if your form's submit
method returns Future<String>
, then T
should be String. Skip T
if it returns Future<void>
Implementation
Future<T> submit<T>() async {
isFormEnabled = false;
if (!isFormValid) {
throw FormInvalidException(TForm);
}
final result = await form.submit(_context);
isFormEnabled = true;
return result;
}