skills/flutter/flutter-bloc/SKILL.md
Implement state management using the BLoC/Cubit pattern with injectable dependency injection. Use when creating new BLoCs, managing UI state transitions, or configuring navigation with GoRouter.
npx skillsauth add dhruvanbhalara/skills flutter-blocInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
sealed class for both States and Events to ensure exhaustive UI handling and compile-time safety.final and Equatable or freezed)._bloc.dart file MUST include its corresponding _event.dart and _state.dart files using part directives. Each event/state file MUST have a part of directive pointing back to the bloc file. This ensures a single library scope and shared private members.
// auth_bloc.dart
part 'auth_event.dart';
part 'auth_state.dart';
class AuthBloc extends Bloc<AuthEvent, AuthState> { ... }
// auth_event.dart
part of 'auth_bloc.dart';
// auth_state.dart
part of 'auth_bloc.dart';
bloc/ folder. Flat bloc/ directories are STRICTLY prohibited.
presentation/bloc/
└── <bloc_name>/
├── <bloc_name>_bloc.dart
├── <bloc_name>_event.dart
└── <bloc_name>_state.dart
Loading before async work, then Success or Error. Never skip the loading state.transformers (e.g., restartable(), droppable()) for events requiring debouncing (search) or throttling (buttons).BlocBuilder for local UI rebuilds based on stateBlocListener for side effects (navigation, snackbars, dialogs)BlocConsumer when both rebuild and side effects are neededcontext.read<Bloc>().add(Event()) for dispatching eventscontext.watch<Bloc>().state for reactive rebuilds (inside build() only)Follow this sequential workflow when adding or updating a BLoC. Copy the checklist to track progress.
Equatable with correct props or freezed.Loading → Success/Error pattern.dart format.injectable for dependency injection and service location@injectable for screen-specific BLoCs to ensure a fresh instance per screen access.@lazySingleton for global or shared BLoCs (e.g., AuthBloc, ThemeBloc, SettingsBloc, PasswordBloc).GoRouter configuration. Use static constants in AppRoutes.ShellRoute or BlocProvider in app_router.dart when shared across multiple screens or within a feature branch.BlocProvider in individual screen build() methods if the BLoC is needed by a feature set.Repository or Bloc injection.development
Perform REST API networking operations (GET, POST, PUT, DELETE) using the lightweight and robust standard `http` package, including platform configurations and background parsing models.
development
Configure internationalization and localization support using Flutter's built-in l10n system, App Resource Bundle (ARB) files, and ICU formatting syntax.
development
Create model classes with fromJson/toJson using dart:convert and Dart 3 pattern matching. Use when manually mapping JSON to classes, parsing HTTP responses, or choosing between manual and code-generated serialization.
data-ai
Diagnose and fix Flutter layout constraint violations (RenderFlex overflow, unbounded height/width, ParentData misuse). Use when encountering layout exceptions, yellow-black overflow stripes, or red error screens.