validate method
Validate the data in the form.
Returns True if the validation is successful.
If you enter a value in initial
, you can set it to the initial value.
If autoUnfocus
is true
, the focus will be removed automatically.
Implementation
bool validate({
bool autoUnfocus = true,
DynamicMap initial = const {},
}) {
if (autoUnfocus) {
_context.unfocus();
}
if (key.currentState == null) {
return false;
}
if (!key.currentState!.validate()) {
return false;
}
initial.forEach((key, value) {
if (key.isEmpty || value == null) {
return;
}
_context[key] = value;
});
key.currentState!.save();
return true;
}