Bloc State Management Rules
A convention playbook for designing, implementing, and testing Cubits and Blocs in Flutter with bloc/flutter_bloc.
Dev & CodingIntermediate★ 617⑂ 59AI score 9/10Last updated: Aug 21, 2026
What it does
- Gives a clear decision table for
CubitvsBloc(simple state → Cubit; event traceability, debounce/throttle → Bloc with transformers). - Enforces naming conventions (past-tense events, noun states) and explains when to model state as a
sealed classhierarchy versus a single class with astatusenum. - Codifies
Equatable/@immutable/copyWithrules, a lookup table forBlocProvider,BlocBuilder,BlocListener,BlocConsumer,BlocSelector, and the three-layer boundary (Presentation → Bloc → Repository → DataProvider). - Ships ready-to-copy
bloc_test+mocktailtest templates plus a pitfalls table (duplicate emissions, missingprops, logic in widgets).
Who it's for
- Flutter developers and teams standardizing on the bloc architecture.
- Tech leads who want consistent conventions and review criteria.
- Anyone who wants Claude Code to generate idiomatic Cubit/Bloc code every time.
Examples
- "Create a Cubit for the login feature" → produces a status-enum state class with
copyWithand a proper loading/success/failure emit flow. - "Refactor this screen from setState to bloc" → moves logic into a Cubit and rewires the UI with
BlocBuilderplusBlocListenerfor snackbars/navigation. - "Write tests for LoginCubit" → generates
blocTestcases asserting emitted state sequences for both success and thrown-exception paths.
· · · 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/bloc⚠ This is a third-party skill. Check the source repository before installing.
- Open a terminal and clone the repo:
git clone https://github.com/evanca/flutter-ai-rules.git - Create the skills directory if needed:
mkdir -p ~/.claude/skills - Copy just this skill:
cp -r flutter-ai-rules/skills/bloc ~/.claude/skills/bloc - Verify that
~/.claude/skills/bloc/SKILL.mdexists. - Restart Claude Code; the skill activates automatically when you ask for Cubit/Bloc work in a Flutter project.
- Make sure your
pubspec.yamlincludesflutter_blocandequatable(plusbloc_testandmocktailfor tests) so the sample code compiles as-is.
View source on GitHub ↗License: MIT