validateAndSave method
- @Deprecated("Use validate instead. This method will be removed in the next major version.")
- bool autoUnfocus = true,
Validation is performed on all forms placed under Form to which key is passed, and if there are no problems, onSaved
is executed.
If the validation is problematic, false
is returned.
The onSaved
is only executed if true
is returned.
If autoUnfocus
is true
, the focus on the form is released.
keyを渡したFormの配下に置かれているすべてのフォームでバリデーションを行ない、問題なければonSaved
が実行されます。
バリデーションが問題ある場合はfalse
が返されます。
onSaved
が実行されるのはtrue
が返される場合のみです。
autoUnfocus
がtrue
の場合、フォームにあるフォーカスが解除されます。
Implementation
@Deprecated(
"Use validate instead. This method will be removed in the next major version.",
)
bool validateAndSave({bool autoUnfocus = true}) {
if (autoUnfocus) {
FocusManager.instance.primaryFocus?.unfocus();
}
if (key.currentState == null) {
if (!_validate()) {
return false;
}
_save();
return true;
}
if (!key.currentState!.validate()) {
return false;
}
key.currentState!.save();
return true;
}