flutter_bloc

Business Logic Component (BLoC) pattern implementation for Flutter. flutter_bloc separates UI from business logic using Streams — Events flow in, States flow out. Two APIs: Bloc (event-driven, explicit event classes) and Cubit (simpler, method-based state updates). BlocProvider injects blocs into widget trees, BlocBuilder/BlocListener/BlocConsumer react to state changes. Widely adopted alternative to Riverpod for teams preferring explicit event-driven architecture.

Evaluated Mar 06, 2026 (0d ago) v8.x
Homepage ↗ Repo ↗ Developer Tools dart flutter state-management bloc cubit events states stream reactive
⚙ Agent Friendliness
68
/ 100
Can an agent use this?
🔒 Security
90
/ 100
Is it safe for agents?
⚡ Reliability
87
/ 100
Does it work consistently?

Score Breakdown

⚙ Agent Friendliness

MCP Quality
--
Documentation
90
Error Messages
85
Auth Simplicity
95
Rate Limits
95

🔒 Security

TLS Enforcement
100
Auth Strength
88
Scope Granularity
82
Dep. Hygiene
90
Secret Handling
88

Client-side state management — no network exposure. State is in-memory only. No credentials stored in BLoC state by convention.

⚡ Reliability

Uptime/SLA
90
Version Stability
88
Breaking Changes
82
Error Recovery
88
AF Security Reliability

Best When

You're building complex Flutter apps with multiple state machines, want explicit event-driven architecture, or prefer BLoC's separation of concerns over Riverpod's provider model.

Avoid When

Your app is simple or your team finds Riverpod's approach more intuitive. BLoC's event boilerplate adds friction for simple use cases where Cubit or Riverpod would suffice.

Use Cases

  • Manage agent app state with explicit event types — BLoC's event/state separation makes agent state transitions auditable via BlocObserver logging
  • Implement reactive UI updates in Flutter using BlocBuilder that only rebuilds when relevant state changes — reduces unnecessary widget rebuilds
  • Track agent workflow state machines using BLoC's Stream-based state — each BLoC models a distinct state machine with typed states
  • Add global state observation for analytics and debugging using BlocObserver — intercept all events and state transitions across the app
  • Share state across widget subtrees using MultiBlocProvider without passing state down the widget tree manually

Not For

  • Simple apps with minimal state — BLoC's event/state boilerplate is heavy for apps with few state objects; use Cubit or Provider instead
  • Teams unfamiliar with Streams and reactive programming — BLoC's Stream-based model has a learning curve beyond basic Flutter state management
  • Server-side Dart — BLoC is UI/Flutter focused; not suitable for server-side state management

Interface

REST API
No
GraphQL
No
gRPC
No
MCP Server
No
SDK
Yes
Webhooks
No

Authentication

Methods: none
OAuth: No Scopes: No

BLoC is a state management library — authentication state is typically modeled as an AuthBloc. No built-in auth.

Pricing

Model: open_source
Free tier: Yes
Requires CC: No

bloc, flutter_bloc, bloc_test, hydrated_bloc, replay_bloc are all MIT licensed and free. Maintained by Felix Angelov.

Agent Metadata

Pagination
none
Idempotent
Full
Retry Guidance
Documented

Known Gotchas

  • BLoC emits the same state type consecutively — BLoC only emits when state != previousState; use Equatable or manually implement == to enable correct equality comparison
  • BlocListener vs BlocBuilder confusion — BlocBuilder rebuilds UI on state, BlocListener triggers side effects (navigation, snackbars); using BlocBuilder for side effects causes duplicate triggers on rebuild
  • Bloc.close() must be called to cancel Streams — BLoCs added manually (not via BlocProvider) must be closed in dispose(); BlocProvider handles automatic closing
  • BlocProvider.of vs context.read — BlocProvider.of traverses widget tree at call time; using it in build() subscribes to rebuilds; context.read() in event handlers avoids unnecessary rebuilds
  • Cubit vs BLoC choice — Cubit (method-based) is simpler but loses event history for debugging; BLoC (event-based) enables BlocObserver event replay but adds boilerplate
  • hydrated_bloc for persistence requires HydratedStorage initialization before runApp — forgetting to await HydratedBloc.storage = await HydratedStorage.build() causes app startup errors

Alternatives

Full Evaluation Report

Detailed scoring breakdown, competitive positioning, security analysis, and improvement recommendations for flutter_bloc.

$99

Scores are editorial opinions as of 2026-03-06.

5229
Packages Evaluated
26151
Need Evaluation
173
Need Re-evaluation
Community Powered