bloc-state-management

Structure Flutter feature state management with Cubit and Bloc patterns.

2|Updated Aug 13, 2023
One-click install
npx skills add https://github.com/NNPopov/movie-theater-tickets --skill bloc-state-management-nnpopov
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: bloc-state-management
Source: https://github.com/NNPopov/movie-theater-tickets/tree/main/src/clients/.claude/skills/bloc-state-management
Command: npx skills add https://github.com/NNPopov/movie-theater-tickets --skill bloc-state-management-nnpopov

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps you design, implement, and refine Flutter feature state management so screens react predictably to async work, user actions, and server responses without tangled UI logic.

Core Features & Use Cases

  • Cubit-first orchestration: Choose the simplest state machine for most feature slices and keep application logic out of widgets.
  • Sealed state modeling: Represent idle, loading, success, and error phases with Freezed-backed sealed states for exhaustive UI handling.
  • Async flow wiring: Connect buttons, use cases, and screen reactions cleanly when a slice loads data, submits forms, or handles failures.
  • Bloc and test guidance: Apply Bloc only when event streams, throttling, or traceability are required, and keep bloc_test coverage aligned with the state contract.
  • Use case example: Build a ticket-selection screen that emits loading while reserving seats, then updates the UI on success or surfaces a typed failure on error.

Quick Start

Ask for a Flutter state design that uses Cubit, Freezed sealed states, and clean loading and error handling for the screen you are building.

Frequently Asked Questions about bloc-state-management

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I manage Flutter feature state with Cubit and sealed Freezed states?

To manage Flutter feature state, use Cubit as the default state machine and define sealed Freezed states to represent idle, loading, success, and error phases for predictable UI reactions. This approach keeps application logic entirely out of your widgets.

When should I use Bloc instead of Cubit for Flutter state management?

Use Bloc instead of Cubit for Flutter state management when your feature requires complex event streams, throttling, or detailed event traceability. Cubit serves as the first-choice default for most slices, keeping orchestration simpler until advanced stream control is needed.

How do I handle async use cases and error handling in Flutter BLoC?

Handle async use cases in Flutter BLoC by wiring use cases that return Either types to your Cubit or Bloc, emitting loading states during execution, then updating the UI on success or surfacing typed failure errors on the error state.

What is the best way to test Flutter Cubit state transitions with bloc_test?

The best way to test Flutter Cubit state transitions is using bloc_test to verify that your sealed Freezed state contracts hold during loading, success, and error transitions. This ensures your state machine maps cleanly to expected async use case outputs.

Does clean architecture with Flutter require Either-returning use cases for state management?

Yes, clean architecture in Flutter requires Either-returning use cases to explicitly model typed failures. This allows your Cubit or Bloc to branch state emissions predictably between success and typed error states during async orchestration.