# Flutter Bloc State Management

> Standards for predictable state management using flutter_bloc, freezed, and equatable. Use when this capability is needed.

- Skill: `tomevault-io/flutter-bloc-state-management` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds@latest add tomevault-io/flutter-bloc-state-management`
- Raw SKILL.md: https://api.skillmd.com/api/skills/tomevault-io/flutter-bloc-state-management/raw
- Safety review: pending (external: skill-scanner PASS, skillspector PASS)
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: AI & ML
- Author: tomevault-io (https://skillmd.com/u/tomevault-io)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/tomevault-io/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

---
> Source: [fierzone/agent-skills-standard](https://github.com/fierzone/agent-skills-standard) — distributed by [TomeVault](https://tomevault.io).
<!-- tomevault:4.0:skill_md:2026-06-16 -->

