# Flutter BLoC State Management

> Standards for predictable state management using flutter_bloc, freezed, and equatable.

- Skill: `fierzone/flutter-bloc-state-management` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds@latest add fierzone/flutter-bloc-state-management`
- Raw SKILL.md: https://api.skillmd.com/api/skills/fierzone/flutter-bloc-state-management/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: fierzone (https://skillmd.com/u/fierzone)
- Updated: 2026-09-10
- Page: https://skillmd.com/skills/fierzone/flutter-bloc-state-management

---


# BLoC State Management

## **Priority: P0 (CRITICAL)**

## Structure

```text
lib/features/auth/
├── bloc/
│   ├── auth_bloc.dart
│   ├── auth_event.dart # (@freezed or Equatable)
│   └── auth_state.dart # (@freezed or Equatable)
```

## Implementation Guidelines

- **States & Events**: Use `@freezed` for union states. See [references/bloc_templates.md](references/bloc_templates.md).
- **Error Handling**: Use `Failure` objects; avoid throwing exceptions.
- **Async Data**: Use `emit.forEach` for streams.
- **Concurrency**: Use `transformer` for event debouncing.
- **Testing**: Use `blocTest` for state transition verification.
- **Injection**: Register BLoCs as `@injectable` (Factory).

## Anti-Patterns

- **No .then()**: Use `await` or `emit.forEach()` to emit states.
- **No Logic in Builder**: Perform calculations in BLoC, not inside `BlocBuilder`.
- **No BLoC-to-BLoC**: Use streams to coordinate BLoCs, not direct references.

## Related Topics

layer-based-clean-architecture | dependency-injection | error-handling

