Listen to Events instead of States with Flutter BLOC


I am using the Flutter BLOC library (
I know there is a way to “listen to” BLOC states changes (with the listen() function)

chatBloc.listen((chatState) async {
      if (chatState is ChatStateInitialized) {
        // do something

But is there a way to listen to BLOC events instead ? Just like I would do with a classical StreamController ?
Thanks to all who will be willing to help 🙂



Yes, you can listen to BLoC events by below code:

BlocSupervisor.delegate = MyBlocDelegate();

And your main.dart similar to below code:

void main() {
  BlocSupervisor.delegate = MyBlocDelegate();

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
      home: BlocProvider<CounterBLoC>(
        create: (ctx) => CounterBLoC(),
        child: TestBlocWidget(),

Here is your bloc_delegate.dart for listen to events of BLoC:

import 'package:bloc/bloc.dart';

class MyBlocDelegate extends BlocDelegate {
  void onEvent(Bloc bloc, Object event) {
    super.onEvent(bloc, event);

  void onError(Bloc bloc, Object error, StackTrace stackTrace) {
    super.onError(bloc, error, stackTrace);

  void onTransition(Bloc bloc, Transition transition) {
    super.onTransition(bloc, transition);

Answered By – Taleb

Answer Checked By – Willingham (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *