fireEvent<T> method
Convenience function that will find the closest BlocEventChannel in the BuildContext and calls fireEvent
withDelay
will cause the event to be fired with a short delay. This is
useful when calling fireEvent in initState or other parts of the Widget
building command to avoid interrupting the draw function.
Implementation
void fireEvent<T>(
BlocEventType<T> eventType,
T payload, {
bool withDelay = false,
}) {
if (withDelay) {
Future<void>.delayed(Duration.zero)
.then((_) => fireEvent(eventType, payload));
return;
}
read<BlocEventChannel>().fireEvent(eventType, payload);
}