addHandler<TEvent extends BlocEvent> method
void
addHandler<TEvent extends BlocEvent>()
Add an async Bloc event handler. getState gets the current Bloc state. Because this function is async, the the state may change between async calls. The event is the event that was sent to the Bloc. updateState is a function that updates the Bloc state. Call this to set state on things like progress indicators in a long running process. pageScope is an optional object that can be used for the lifetime of the page.
Implementation
void addHandler<TEvent extends BlocEvent>(
Future<T> Function(
T Function() getState,
TEvent event,
void Function(T) updateState,
Object? pageScope,
)
handler,
) =>
_handlersByEvent.putIfAbsent(
TEvent,
() => (getState, event, updateState, pageScope) =>
handler(getState, event as TEvent, updateState, pageScope),
);