dimitriremoiville/cc-mobile/bloc-state
Claude Code and agent skill by dimitriremoiville/cc-mobile
- community
Checking that the SKILL.md file is still in the repository.
How state is shaped with flutter_bloc in this project — Bloc vs Cubit, freezed unions for states/events, bloc_concurrency transformers instead of manual in-flight flags, one-shot effects, and testing with bloc_test.
Install
npx vskill@latest install dimitriremoiville/cc-mobile/bloc-stateSKILL.md
The same SKILL.md was published earlier as dimitriremoiville/cc-mobile/bloc-state.
Bloc state
Bloc vs Cubit
- Cubit — a set of methods that produce states. Best for: settings toggle, filter controls, simple screen state.
- Bloc — discrete events → states. Best for: auth, checkout, forms, anything with "submit" semantics where concurrency and ordering matter.
If you'd write the same method two different ways depending on "is it busy?", you want a Bloc with a transformer.
Canonical Bloc shape
Rules:
- Events and states are freezed sealed unions.
.mapandswitchare both exhaustive. - The bloc's public surface is the
add(event)method +stategetter +stream. Don't add custom methods. - All
emits happen in event handlers. Noemitfrom outsideon<...>.
bloc_concurrency transformers
Use the right transformer instead of guarding with booleans:
- `droppable()` — ignore new events while one is in flight. Form submissions, "Sign in", any non-idempotent action.
- `restartable()` — cancel the in-flight one and run the new. Search, filters, anything that supersedes the last.
- `sequential()` — queue. Uploads, analytics events, ordered writes.
- `concurrent()` (default) — just don't rely on order.
If you see this in existing code, it's an anti-pattern to replace:
State shape — union vs single state
Use a union when states carry different data:
Use a single state when fields overlap and only a status changes:
Union when the UI looks fundamentally different per state. Single when the UI keeps its shape and only a button / banner changes.
One-shot effects
Snackbars, navigation, toasts, vibration — never as states. Two patterns:
Pattern A — effect field in state (easiest, good default)
The view uses BlocListener with listenWhen and the bloc clears the effect on the next state change:
Pattern B — separate Stream<Effect> controller
When effects must fire independently of state changes. Add a StreamController<Effect> in the bloc, close it in close(), expose Stream<Effect> get effects.
Pick one per feature, don't mix.
Error surface
- Blocs never know about
DioException. They receiveFailureviaEither. - Failures map to UI either as an error state or an effect (snackbar).
- For forms, surface
ValidationFailure.fieldsinto per-fieldformzinputs.
Lifecycle
close()overrides must callsuper.close(). Cancel subscriptions there.- Never
await-loop insideclose(). The BLoC is being disposed; if you need a long shutdown, do it before the widget goes away.
Testing
Keep a single concept per test. See ${CLAUDE_PLUGIN_ROOT}/skills/flutter-testing/SKILL.md. Rough template:
Hard nos
- No
Equatableon new states/events. Freezed. - No
_isProcessingflags.droppable()/restartable()/sequential(). - No effects encoded as states ("ShowSnackbarState"). Use an effect field or a separate stream.
- No direct dio/api calls in a bloc. Repository only.
- No
.then(...)chains in handlers. Await.
Security
- Security scanPassed, 90 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingplugins/cc-mobile-flutter/skills/bloc-state/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/dimitriremoiville/cc-mobile/bloc-state)