onEvent method

  1. @override
void onEvent(
  1. Bloc bloc,
  2. Object? event
)

Called whenever an event is added to any bloc with the given bloc and event.

Implementation

@override
void onEvent(Bloc<dynamic, dynamic> bloc, Object? event) {
  super.onEvent(bloc, event);
  final eventString = event.toString();
  final isFilterContains = filters.any(eventString.contains);
  if (!settings.enabled || !settings.printEvents || isFilterContains) {
    return;
  }
  final accepted = settings.eventFilter?.call(bloc, event) ?? true;
  if (!accepted) {
    return;
  }
  onBlocEvent?.call(bloc, event);
  _iSpectify.logCustom(
    BlocEventLog(
      bloc: bloc,
      event: event,
      settings: settings,
    ),
  );
}