> flutter-bloc-state-management
Standards for predictable state management using flutter_bloc, freezed, and equatable. Use when implementing BLoC pattern for state management in Flutter. (triggers: **_bloc.dart, **_cubit.dart, **_state.dart, **_event.dart, BlocProvider, BlocBuilder, BlocListener, Cubit, Emitter)
curl "https://skillshub.wtf/HoangNguyen0403/agent-skills-standard/flutter-bloc-state-management?format=md"BLoC State Management
Priority: P0 (CRITICAL)
You are a Flutter State Management Expert. Design predictable, testable state flows.
State Design Workflow
- Define Events: What happens? (UserTap, ApiSuccess). Use
@freezed. - Define States: What needs to show? (Initial, Loading, Data, Error).
- Implement BLoC: Map Events to States using
on<Event>. - Connect UI: Use
BlocBuilderfor rebuilds,BlocListenerfor side effects.
Implementation Guidelines
- States & Events: Use
@freezedfor union types. - Error Handling: Emit
Failurestates; never throw exceptions inon<Event>. - Async Data: Use
emit.forEachfor streams. - Concurrency: Use
transformer: restartable()for search/typeahead.
Verification Checklist (Mandatory)
- Initial State: Defined and tested?
- Test Coverage:
blocTestused for ALL states? - UI Logic: No complex calculation in
BlocBuilder? - Side Effects: Navigation/Snackbars in
BlocListener(NOT Builder)?
Anti-Patterns
- No .then(): Use
awaitoremit.forEach()to emit. - No BLoC-to-BLoC: Use
StreamSubscriptionorBlocListener, not direct refs. - No Logic in Builder: Move valid logic to BLoC.
References
> related_skills --same-repo
> typescript-tooling
Development tools, linting, and build config for TypeScript. Use when configuring ESLint, Prettier, Jest, Vitest, tsconfig, or any TS build tooling. (triggers: tsconfig.json, .eslintrc.*, jest.config.*, package.json, eslint, prettier, jest, vitest, build, compile, lint)
> typescript-security
Secure coding practices for TypeScript. Use when validating input, handling auth tokens, sanitizing data, or managing secrets and sensitive configuration. (triggers: **/*.ts, **/*.tsx, validate, sanitize, xss, injection, auth, password, secret, token)
> typescript-language
Modern TypeScript standards for type safety and maintainability. Use when working with types, interfaces, generics, enums, unions, or tsconfig settings. (triggers: **/*.ts, **/*.tsx, tsconfig.json, type, interface, generic, enum, union, intersection, readonly, const, namespace)
> typescript-best-practices
Idiomatic TypeScript patterns for clean, maintainable code. Use when writing or refactoring TypeScript classes, functions, modules, or async logic. (triggers: **/*.ts, **/*.tsx, class, function, module, import, export, async, promise)