validateForm method
Validate the enclosing Form
Implementation
void validateForm({VoidCallback? onSuccess}) {
// Clear current focus
clearFocus();
// Find closest Form ancestor
// Throw if no Form ancestor is found
final form = Form.of(this);
// Validate form
if (form.validate()) {
form.save();
onSuccess?.call();
}
}