VeryGoodOpenSource / formz

A unified form representation in Dart used at Very Good Ventures 🦄
https://pub.dev/packages/formz
MIT License
392 stars 39 forks source link

example/lib/main.dart #95

Closed andreas1724 closed 1 year ago

andreas1724 commented 1 year ago

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?