bloc

Featured

Use when creating a Cubit or Bloc, modeling state with sealed classes or status enums, wiring BlocBuilder/BlocListener/BlocProvider, writing bloc tests, or choosing between Cubit and Bloc.

AI & Automation 619 stars 60 forks Updated today MIT

Install

View on GitHub

Quality Score: 95/100

Stars 20%
93
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

# Bloc Skill Design, implement, and test state management using the [bloc](https://pub.dev/packages/bloc) and [flutter_bloc](https://pub.dev/packages/flutter_bloc) libraries. ## When to Use Use this skill when: * Creating a new Cubit or Bloc for a feature. * Modeling state (choosing between sealed classes and a single state class with status enum). * Wiring `BlocBuilder`, `BlocListener`, `BlocConsumer`, or `BlocProvider` in the widget tree. * Writing unit tests for a Cubit or Bloc. * Deciding between Cubit and Bloc. * Refactoring existing state management to follow bloc conventions. --- ## 1. Cubit vs Bloc | Situation | Use | |---|---| | Simple state, no events needed | `Cubit` | | Complex flows, event traceability needed | `Bloc` | | Advanced event processing (debounce, throttle) | `Bloc` with event transformers | **Default to `Cubit`. Refactor to `Bloc` only when requirements grow.** --- ## 2. Naming Conventions ### Events (Bloc only) - Named in **past tense**: `LoginButtonPressed`, `UserProfileLoaded`. - Format: `BlocSubject` + optional noun + verb. - Initial load event: `BlocSubjectStarted` (e.g., `AuthenticationStarted`). - Base event class: `BlocSubjectEvent`. ### States - Named as **nouns** (states are snapshots in time). - Base state class: `BlocSubjectState`. - Sealed subclasses: `BlocSubject` + `Initial` | `InProgress` | `Success` | `Failure`. - Example: `LoginInitial`, `LoginInProgress`, `LoginSuccess`, `LoginFailure`. - Single-class approach: `BlocSu...

Details

Author
evanca
Repository
evanca/flutter-ai-rules
Created
1 years ago
Last Updated
today
Language
Shell
License
MIT

Similar Skills

Semantically similar based on skill content — not just same category