emit method

void emit(
  1. SimpleState state
)
inherited

Emits a new state if it's different from the current state.

The comparison uses the == operator, which for Equatable states will use the equatable comparison, and for other states will use their overridden equality or reference equality.

This method only triggers listeners if the new state is actually different.

Example:

emit(state.copyWith(count: state.count + 1));

Implementation

void emit(S state) {
  if (state != value) {
    value = state;
  }
}