reset method

void reset(
  1. S initialState
)

Resets the bloc to its initial state.

initialState is the state to reset the bloc to.

This method directly emits the initial state, bypassing the normal event-driven state changes. It's useful for resetting the bloc to a known state, typically when cleaning up or reinitializing.

Note: This method uses a protected API and should be used cautiously.

Usage:

void cleanUpBloc() {
  reset(MyInitialState());
}

Implementation

void reset(S initialState) {
  // ignore: invalid_use_of_visible_for_testing_member
  super.emit(initialState);
}