Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Updating Email.pure to Email.dirty in flutter_form_validation example #3973

Closed
wants to merge 2 commits into from
Closed

Conversation

Nana-Kwame-bot
Copy link

fix: MyFormBloc Email and Password validation

fix: Removing redundant FormzInputs

Status

READY

Breaking Changes

NO

Description

In the flutter_form_validation we have this method

  void _onEmailChanged(EmailChanged event, Emitter<MyFormState> emit) {
    final email = Email.dirty(event.email);
    emit(
      state.copyWith(
        email: email.isValid ? email : Email.pure(event.email),
        isValid: Formz.validate([email, state.password]),
      ),
    );
  }

As you can see we're passing Email.pure instead of Email.dirty to the email field in the MyFormState. After changing pure to dirty, I realized that it was redundant having email.isValid since Email.dirty does automatic validation for that input so I took it out. Now we only have:

void _onEmailChanged(EmailChanged event, Emitter<MyFormState> emit) {
    final email = Email.dirty(event.email);
    emit(
      state.copyWith(
        email: email,
        isValid: Formz.validate([email, state.password]),
      ),
    );
  }

Same thing applied to the _onPasswordChanged method. Targets #3972

Type of Change

  • ✨ New feature (non-breaking change which adds functionality)
  • 🛠️ Bug fix (non-breaking change which fixes an issue)
  • ❌ Breaking change (fix or feature that would cause existing functionality to change)
  • 🧹 Code refactor
  • ✅ Build configuration change
  • 📝 Documentation
  • 🗑️ Chore

fix: MyFormBloc Email and Password validation

fix: Removing redundant FormzInputs
fix: Updated pubspect.yaml in flutter_todos
in order for TodosOverview tests to pass
@felangel
Copy link
Owner

This is working as expected. See my comment on #3972

@felangel felangel closed this Oct 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants