
Bloc
A Dart library for managing app state in a predictable way using the BLoC pattern.
- Stars
- 12.5k
- Forks
- 3.4k
- Licence
- MIT
- Language
- Dart
- Last update
- 4 days ago
- Type
- Library
What it is
Bloc is a state management library for Dart and Flutter apps. It helps separate what the user sees (the presentation layer) from the business logic that decides what happens, which the README says makes code easier to test and reuse. The project is a family of packages, including bloc, flutter_bloc, bloc_test, and hydrated_bloc.
- Build a counter app with a CounterBloc, as in the official Counter example
- Implement form validation with the bloc and flutter_bloc packages
- Create an infinite-scrolling list or a GitHub search screen, using the linked tutorials
- Write unit tests for business logic with the bloc_test package
Great for
- Flutter developers who want to separate UI code from business logic
- Teams that need code that is easy to unit test
- Apps with complex or asynchronous state, such as data loading or form validation
- Developers who want to follow the BLoC design pattern
Not ideal for
- Beginners with no Dart or Flutter experience, since the library assumes familiarity with streams and the pattern
- Very small apps where a simpler state approach would be enough; the README does not compare overhead for small projects
How to get it
- 1
Install with a package manager
You'll need: Dart SDK or Flutter SDK
Add the Flutter package
flutter pub add flutter_bloc - 2
Run it
- Add flutter_bloc (or bloc for pure Dart) to your project
- Create a Bloc or Cubit class that holds your business logic
- Provide the bloc to your widget tree and use it from your UI
- Start with the official Counter tutorial at bloclibrary.dev
- 3
Get the most out of it
- Use bloc_test to unit test your Blocs
- Use bloc_lint to enforce style rules, as the README badge indicates
- Use hydrated_bloc to persist state between app sessions
- Use bloc_concurrency to control how events are processed
- Read the official docs at bloclibrary.dev for migration and tutorials
Downloads
Strengths
- Separates presentation from business logic, which the README says aids testability and reuse
- Provides a family of packages covering Flutter widgets, testing, concurrency, linting, and persistence
- Has official documentation, a migration guide, and many linked examples
Trade-offs
- Requires understanding of the BLoC pattern and Dart streams, which adds learning effort
- The README is truncated here, so detailed API behavior and version compatibility should be checked in the official docs
How it compares
| Project | Stars | Type | Level | Updated | Best for |
|---|---|---|---|---|---|
| bloc (this) | 12.5k | Library | intermediate | 4 days ago | Flutter developers who want to separate UI code from business logic |
| getx | 11.2k | Library | beginner | 5 days ago | Flutter developers who want state management, routing and dependency injection from a single package |
| mobx | 28.2k | Library | intermediate | 5 days ago | Frontend developers building React apps with complex or frequently changing state |
| dio | 12.8k | Library | beginner | 11 days ago | Flutter app developers who need to call web APIs |
| flame | 10.8k | Library | intermediate | 4 days ago | Flutter developers who want to add a game to an app |
| zustand | 58.9k | Library | beginner | 15 days ago | React developers who want simpler shared state than Redux |
Stats synced from GitHub. The assessment above was drafted with AI from the project's README on 2026-10-29 and may miss recent changes — check the README before relying on a command. MIT licence: free to use, modify and distribute, including commercially, as long as you keep the copyright notice.