0

I am trying to emit a state more than one time because I am validating a form no need to add any thing on the constructor and make copyWith func etc..

so could you help me with other solutions?

    class PersonUnValid extends PersonState {

  const PersonUnValid();

  @override
  List<Object> get props => [];

}
  void validate() {
    personKey.currentState!.save();
    if (Formz.validate(personForm.inputs) == FormzStatus.valid) {
      emit(const PersonValid());
      return;
    }
    emit(PersonUnValid());
  }

Mo_
  • 45
  • 9

1 Answers1

0

emit() will not emit a new state, if it (the state) is identical. This is by design. See:

/// Updates the [state] to the provided [state].
/// [emit] does nothing if the [state] being emitted
/// is equal to the current [state].
void emit(State state) {
...
if (state == _state && _emitted) return;
...

What do you expect the UI should change when the state is the same?

Robert Sandberg
  • 6,832
  • 2
  • 12
  • 30
  • 1
    yes I got it I found an issue on GitHub the owner of equitable suggest on this case to remove the equatable from the base class and added to the subclass – Mo_ May 25 '22 at 09:39