emit method

  1. @override
void emit(
  1. State state
)

emit is only for internal use and should never be called directly outside of tests. The Emitter instance provided to each EventHandler should be used instead.

class MyBloc extends Bloc<MyEvent, MyState> {
  MyBloc() : super(MyInitialState()) {
    on<MyEvent>((event, emit) {
      // use `emit` to update the state.
      emit(MyOtherState());
    });
  }
}

Updates the state of the bloc to the provided state. A bloc's state should only be updated by emitting a new state from an EventHandler in response to an incoming event.

Implementation

@override
void emit(State state) {
  // ignore: invalid_use_of_visible_for_testing_member
  _bloc.emit(state);
}