example/lib/main.dart
andreas1724 opened this issue · comments
The example formz/example/lib/main.dart, which is also the example on pub.dev/formz, does not seem to behave as expected: If I leave the fields for Email and Password empty, the input in _onSubmit
should be rejected, since empty fields do not pass the validator
of either Email
or Password
. However, at program startup or after each _resetForm
call, empty text fields are not rejected.
One could solve the problem by changing all default values of the MyFormState
constructor from pure
to dirty
:
MyFormState({
Email? email,
this.password = const Password.dirty(),
this.status = FormzSubmissionStatus.initial,
}) : email = email ?? Email.dirty();
But I am not sure if this is the right approach. Could you please check this?