Skip to content
pubscout

flutter_bloc

9.1.1, released 2 years ago by bloclibrary.dev

Flutter widgets to easily integrate blocs and cubits for state management.

Flutter FavoriteWASM-readyRock solidQuiet but busy
$ flutter pub add flutter_bloc
Source repository

What it does

Provides widgets like BlocBuilder, BlocListener, and BlocProvider to help integrate BLoC and Cubit state management instances into the Flutter widget tree. It manages lifecycle, dependency injection, and state reactions without requiring code generation.

AI-written summary of version 9.1.1, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You are using the bloc package for state management in Flutter
  • You need a structured way to separate business logic from UI
  • You want to inject blocs into the widget tree and rebuild on state changes

Skip it when

  • You prefer a simpler or less boilerplate-heavy state management solution like riverpod
  • You are not using the bloc package

Strengths

  • Tight integration with the bloc state management library
  • Built-in dependency injection via BlocProvider
  • Reduces boilerplate compared to using raw StreamBuilders

Weaknesses

  • Can introduce significant boilerplate for simple states
  • Steeper learning curve for developers new to the BLoC pattern

Setup

Kind
Flutter widgets
Effort
Low
Code generation
No
Direct dependencies
2
BlocProvider(
  create: (_) => CounterCubit(),
  child: CounterPage(),
);

Alternatives

Packages that do the same job and could replace flutter_bloc.

  • riverpod

    If you want a modern, compile-safe state management library with less boilerplate.

Works with

Packages commonly used together with flutter_bloc: ones it builds on, ones built on it, and its own family.