بنقرة واحدة
flutter-bloc
BLoC/Cubit state management for Flutter — naming, state modeling, widgets, testing, architecture rules.
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
BLoC/Cubit state management for Flutter — naming, state modeling, widgets, testing, architecture rules.
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
استنادا إلى تصنيف SOC المهني
MCP server usage for Dart MCP, Firecrawl, Hugging Face. Tool priorities, commands, workflows.
Development process rules. Use when planning complex tasks, implementing incrementally, managing packages, or following communication guidelines.
Dart 3 patterns including switch/if-case, pattern matching, sealed classes, and records. Use when writing exhaustive switches, destructuring, pattern matching on types, or returning multiple values with records.
Core code quality rules for Dart/Flutter. Use when formatting, handling async/null safety, organizing classes, or following Dart best practices.
Code review checklist for PRs/MRs. Use when reviewing pull requests, examining code changes, or when the user asks for a code review.
Data handling patterns for Dart/Flutter. Use when implementing serialization, caching, layer separation, DTOs, repositories, offline-first, or data validation.
| name | flutter-bloc |
| description | BLoC/Cubit state management for Flutter — naming, state modeling, widgets, testing, architecture rules. |
BlocSubject + noun + verb — LoginButtonPressed, UserProfileLoadedBlocSubjectStartedBlocSubjectEventBlocSubject + Initial | Success | Failure | InProgressBlocSubjectState + BlocSubjectStatus enumBlocSubjectStateEquatable; annotate @immutable; implement copyWith; use const constructorsprops; copy List/Map with List.of/Map.of| Cubit | Bloc |
|---|---|
| Simple state, no events, less boilerplate | Complex event-driven logic, traceability |
Public methods return void/Future<void> | Trigger via add(); no custom public methods |
Start with Cubit; refactor to Bloc if needed.
emit() in try-catchemit inside Cubit/Bloc; never externallystate == nextState) are ignoredBlocObserver in main.dart| Widget | Purpose |
|---|---|
BlocBuilder | Rebuild on state changes (builder must be pure) |
BlocListener | Side effects only (navigation, dialogs) |
BlocConsumer | Builder + listener combined |
BlocSelector | Rebuild only on selected state slice |
BlocProvider / MultiBlocProvider | Provide blocs to subtree |
RepositoryProvider / MultiRepositoryProvider | Provide repos to subtree |
Context access:
context.read<T>() — one-off, no rebuild (callbacks)context.watch<T>() — subscribe and rebuild (inside build)context.select<T, R>() — rebuild on specific slicePrefer BlocBuilder/BlocSelector over context.watch/context.select for explicit scoping. Handle all states in UI: empty, loading, error, populated.
BlocListener to listen to one and add events to anotherblocTest<CounterCubit, CounterState>(
'emits [1] when increment is called',
build: () => CounterCubit(),
act: (cubit) => cubit.increment(),
expect: () => [const CounterState(1)],
);
bloc_test for state transitions; bloc_lint in CI