This commit is contained in:
2025-03-11 11:38:08 +02:00
parent b0835bf865
commit b4b44cbae2

View File

@@ -92,6 +92,7 @@ class _AstromicFormFieldState<T> extends State<AstromicFormField<T>> {
// //
//SECTION - State Variables //SECTION - State Variables
//s1 --State //s1 --State
late bool _useFieldValidation;
late AstromicFieldState _currentState; late AstromicFieldState _currentState;
//s1 --State //s1 --State
// //
@@ -110,6 +111,7 @@ class _AstromicFormFieldState<T> extends State<AstromicFormField<T>> {
//SECTION - State Variables initializations & Listeners //SECTION - State Variables initializations & Listeners
//s1 --State //s1 --State
_currentState = AstromicFieldState.idle; _currentState = AstromicFieldState.idle;
_useFieldValidation = false;
//s1 --State //s1 --State
// //
//s1 --Controllers & Listeners //s1 --Controllers & Listeners
@@ -194,6 +196,9 @@ class _AstromicFormFieldState<T> extends State<AstromicFormField<T>> {
setState(() { setState(() {
if (widget.resetMessageOnChange ?? false) { if (widget.resetMessageOnChange ?? false) {
widget.formController.resetState(widget.formID); widget.formController.resetState(widget.formID);
setState(() {
_useFieldValidation = false;
});
} }
if (widget.onChanged != null) { if (widget.onChanged != null) {
widget.onChanged!(s, _currentState); widget.onChanged!(s, _currentState);
@@ -210,6 +215,7 @@ class _AstromicFormFieldState<T> extends State<AstromicFormField<T>> {
validator: (widget.validators != null && widget.validators!.isNotEmpty) validator: (widget.validators != null && widget.validators!.isNotEmpty)
? (bool enabled, bool focused, String? s) { ? (bool enabled, bool focused, String? s) {
widget.formController.resetState(widget.formID); widget.formController.resetState(widget.formID);
_useFieldValidation = true;
// //
List<FormControllerValidator> validators = <FormControllerValidator>[]; List<FormControllerValidator> validators = <FormControllerValidator>[];
// //
@@ -225,7 +231,7 @@ class _AstromicFormFieldState<T> extends State<AstromicFormField<T>> {
if (checks.containsValue(false)) { if (checks.containsValue(false)) {
// It has an Error! // It has an Error!
_setFieldErrorState(widget.formID, checks.entries.where((MapEntry<FormControllerValidator, bool> e) => e.value == false).toList().first.key.message); _setFieldErrorState(widget.formID, checks.entries.where((MapEntry<FormControllerValidator, bool> e) => e.value == false).toList().first.key.message);
return ''; return _useFieldValidation?'' : null;
} else { } else {
// It has no Errors! // It has no Errors!
return null; return null;