Bloc State Management Rules
A practical rulebook for designing, implementing, and testing Cubits and Blocs in Flutter with bloc/flutter_bloc.
Dev & CodingIntermediate★ 646⑂ 67AI score 9/10Last updated: Sep 14, 2026
What it does
Makes Claude Code follow canonical bloc-ecosystem conventions whenever it writes Flutter state management code.
- Cubit vs Bloc decision table: Cubit by default, Bloc when you need event traceability or transformers (debounce/throttle).
- Naming conventions: past-tense events (
LoginButtonPressed), noun states (LoginInProgress). - State modeling: when to use sealed classes with exhaustive
switchvs a single class with a status enum, plusEquatable,@immutable, andcopyWithrules. - Widget wiring: reference table for BlocProvider, BlocBuilder, BlocListener, BlocConsumer, BlocSelector, and
context.readvswatchrules. - Architecture: Presentation → Business Logic → Data (Repository → DataProvider) boundaries, no bloc-to-bloc calls.
- Testing: ready-to-copy
bloc_test+mocktailtemplates for success and failure paths. - Common pitfalls table with concrete fixes.
Who it's for
- Flutter developers building medium-to-large apps on bloc/flutter_bloc
- Tech leads standardizing state management style across a team
- Teams migrating from setState/Provider to bloc
- Anyone who wants AI-generated state code to be predictable and reviewable
Examples
- "Create a Cubit for the login feature" → generates a status-enum state class with
copyWithand constructor-injected repository. - "Refactor this screen from setState to bloc" → defines sealed states and splits rebuild logic (BlocBuilder) from side effects (BlocListener).
- "Write tests for CartCubit" → produces
blocTestcases asserting the loading/success/failure emission order with propertearDown.
· · · Install guide · · ·
Try it now, no install
Paste this into Claude to use the skill without installing anything.
Read the instructions in this file and follow them to help me: https://raw.githubusercontent.com/evanca/flutter-ai-rules/HEAD/skills/bloc/SKILL.md What I want: (describe your task here)
If Claude can't open the link, open it yourself and paste the contents instead.
↓ If it works for you, download the ZIP below and install it. Then it runs on its own — no pasting each time.
Install in the Claude app (no terminal)
- Download the ZIP with the button below.
- In Claude, open Settings → Capabilities and turn on 'Code execution and file creation'. (one time)
- Go to Customize → Skills → + → 'Upload a skill' and upload the ZIP.
Install in Claude Code
Let Claude do it — paste this into Claude Code
Install the skill I found on Claude Skill Mart. Copy the skills/bloc folder from the GitHub repo evanca/flutter-ai-rules into my ~/.claude/skills/bloc/. When it's done, tell me in one line what this skill can do.
Install with a command instead
git clone https://github.com/evanca/flutter-ai-rules.git && mkdir -p ~/.claude/skills && cp -r flutter-ai-rules/skills/bloc ~/.claude/skills/⚠ This is a third-party skill. Check the source repository before installing.
- Open a terminal.
- Clone the repository:
git clone https://github.com/evanca/flutter-ai-rules.git - Create the skills folder:
mkdir -p ~/.claude/skills - Copy just this skill:
cp -r flutter-ai-rules/skills/bloc ~/.claude/skills/ - Verify it exists:
ls ~/.claude/skills/bloc/SKILL.md - Restart Claude Code inside your Flutter project directory.
- Ask something like "create a Cubit for this feature" and the skill activates automatically. (Your project needs the
bloc/flutter_blocpackages, plusbloc_testandmocktailfor tests.)
View source on GitHub ↗License: MIT