bloc-cubit
Use when working with Flutter Bloc/Cubit state management. Covers when to choose Bloc vs Cubit, how to use bloc and flutter_bloc together, lifecycle, testing, and safe defaults.
What this skill does
# Flutter Bloc/Cubit State Management Use this skill when building Flutter state management with `bloc` and `flutter_bloc`. ## Core Rule - Use `Cubit` for simple, direct state updates. - Use `Bloc` for event-driven flows, transitions, and replayable business logic. - Use `bloc` in Dart-only projects. - Use `flutter_bloc` in Flutter apps when you need widgets like `BlocProvider`, `BlocBuilder`, or `BlocListener`. - If you install `flutter_bloc`, you do not need to add `bloc` separately in a Flutter app because `flutter_bloc` depends on it. ## Decision Guide Choose `Cubit` when: - state changes are simple method calls - you do not need events - the feature is local and low complexity - examples include counters, toggles, filters, form flags, and theme mode Choose `Bloc` when: - user actions should be modeled as explicit events - the flow has loading, success, and failure transitions - the logic benefits from clear state machines - examples include auth, pagination, checkout, sync, and multi-step workflows ## Required Project Setup For Dart-only code: - add `bloc` - do not add `flutter_bloc` unless Flutter widgets are needed For Flutter UI code: - add `flutter_bloc` - let it bring `bloc` transitively - use `BlocProvider` at the feature boundary - use `BlocBuilder` for rebuilds and `BlocListener` for side effects ## Implementation Pattern Prefer this structure: - repository or service owns I/O - bloc/cubit owns state and orchestration - UI only dispatches actions and renders state Keep state immutable. Keep events explicit when using `Bloc`. Keep one bloc or cubit per feature responsibility. ## Lifecycle Rules - Close manually created blocs and cubits with `close()`. - Do not manually close instances owned by `BlocProvider`. - Use `BlocProvider` or `MultiBlocProvider` to let Flutter manage disposal. - If you create a bloc/cubit with `new` or a constructor outside the widget tree, you own its lifecycle. ## UI Binding Rules Use `BlocBuilder` when the widget should rebuild from state. Use `BlocListener` when the widget should react without rebuilding. Use `BlocConsumer` only when both are needed in one place. Use `buildWhen` and `listenWhen` when rebuilds or listeners need narrowing. Use `BlocSelector` when only one field should drive rebuilds. ## Testing Rules - Test `Cubit` by calling methods and asserting emitted states. - Test `Bloc` by adding events and asserting the transition sequence. - Mock repositories at the boundary, not inside the bloc logic. - Test side effects separately from rendering logic. ## Common Pitfalls - Do not put network calls directly in widgets. - Do not use `Bloc` for trivial local state. - Do not add both `bloc` and `flutter_bloc` in a Flutter app when only `flutter_bloc` is needed. - Do not forget `close()` for manually managed instances. - Do not emit duplicate states unless the transition is meaningful. - Do not let a single bloc grow into an app-wide dumping ground. ## What To Prefer In Answers When writing code or advising on design: - show the smallest working Bloc or Cubit first - mention why Bloc or Cubit was chosen - mention whether the dependency should be `bloc` or `flutter_bloc` - include cleanup and testing notes if lifecycle is manual - keep examples aligned with the current Flutter state management docs and the bloc package docs ## Minimal Reference Checklist - `bloc` = core logic package - `flutter_bloc` = Flutter UI integration package - `Cubit` = method-based updates - `Bloc` = event-based transitions - manual creation = manual `close()` - provider-owned instance = no manual `close()`
Related in General
modeling-omnistudio-epc-catalog
IncludedSalesforce Industries CME EPC product-modeling skill for Product2-based catalog creation. Use when creating EPC products, configuring product attributes, building offer bundles with Product Child Items, or reviewing EPC DataPack JSON metadata for product catalog changes. TRIGGER when: user creates or updates Product2 EPC records, AttributeAssignment payloads, AttributeMetadata/AttributeDefaultValues, Offer bundles, or ProductChildItem relationships. DO NOT TRIGGER when: designing OmniScripts/FlexCards/Integration Procedures (use building-omnistudio-omniscript, building-omnistudio-flexcard, or building-omnistudio-integration-procedure), implementing Apex business logic (use generating-apex), or troubleshooting deployment pipelines (use deploying-metadata).
relationship-science-coach
IncludedUse this skill for direct, practical adult relationship coaching: couples conflict, repair, trust, marriage, dating, flirting, attachment patterns, emotional connection, sex, desire differences, eroticism, kink negotiation, affection, love languages, breakups, and long-term passion. Draw on Gottman, EFT and Hold Me Tight, attachment science, modern sex research, Perel, Nagoski, Kerner, Schnarch, Love and Stosny, and flexible love-language tools. Be concrete and low-hedge. Redirect only for imminent danger, abuse, coercive control, minors, non-consent, self-harm, stalking, or medical/legal/psychiatric decisions.
building-sf-integrations
IncludedSalesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), or data import/export (use handling-sf-data).
venue-templates
IncludedAccess comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
let-fate-decide
IncludedDraws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated. Interprets the spread to guide next steps. Use when the user says 'let fate decide', 'YOLO', 'whatever', 'idk', or other nonchalant phrases, makes Yu-Gi-Oh references, or when you are about to arbitrarily pick between multiple reasonable approaches. Prefer over ask-questions-if-underspecified when the user's tone is casual or playful rather than precision-seeking.
net-ops
IncludedCross-platform network troubleshooting (Windows, macOS, Linux) via local or remote shell. Use for: DNS broken, can't resolve hostnames, nslookup/dig works but apps fail, NRPT, WFP, scutil, /etc/resolver, systemd-resolved, /etc/resolv.conf, NetworkManager, VPN DNS leak residue (ProtonVPN/Mullvad/WireGuard/AnyConnect), AV/firewall blocking DNS or DoH, Tailscale DNS interaction, intermittent connectivity, remote diagnostics over SSH.