bloc

Implement and test Flutter state management with Cubit and Bloc patterns.

1|Updated Aug 14, 2026
One-click install
npx skills add https://github.com/sohampawar1866/zeromile-go --skill bloc-sohampawar1866
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: bloc
Source: https://github.com/sohampawar1866/zeromile-go/tree/main/.agents/skills/bloc
Command: npx skills add https://github.com/sohampawar1866/zeromile-go --skill bloc-sohampawar1866

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Flutter developers often struggle with structuring state management consistently, choosing between Cubit and Bloc, modeling states correctly, and wiring widgets without introducing bugs like duplicate emissions or missing Equatable props. ## Core Features & Use Cases - Cubit vs Bloc Guidance: Decide when a simple Cubit suffices and when event-driven Bloc with transformers is required. - State Modeling Patterns: Model state with sealed classes or a single class with a status enum, following Equatable and immutability rules. - Widget Wiring & Testing: Wire BlocProvider, BlocBuilder, BlocListener, and BlocConsumer correctly, and write bloc_test unit tests with mocktail. - Use Case: When building a login feature, use this Skill to scaffold a LoginCubit with a status-enum state, connect it to the widget tree with BlocBuilder and BlocListener, and generate blocTest cases covering loading, success, and failure emissions. ## Quick Start Use the bloc skill to create a LoginCubit with sealed states, wire it into my Flutter login screen, and generate bloc tests for the success and failure paths.

Frequently Asked Questions about bloc

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

FAQPage Schema
How do I choose between Cubit and Bloc in Flutter?

Use Cubit for simple state without events, and Bloc when you need event traceability or advanced event processing like debounce and throttle via transformers. Default to Cubit and refactor to Bloc only when requirements grow.

How do I write unit tests for a Cubit or Bloc?

Use the bloc_test package with mocktail to mock repositories. The blocTest function takes build, act, and expect blocks to assert emitted state sequences, and you should always call cubit.close() in tearDown.

Should I use sealed classes or a status enum for bloc state?

Use sealed classes when states are mutually exclusive with subclass-specific properties and you want exhaustive switch handling. Use a single class with a status enum when states share many properties or previous data must be retained after failure.

Why is my BlocBuilder not rebuilding after emit?

Bloc ignores duplicate states based on equality, so emitting the same instance or an equal state triggers no rebuild. Always emit a new state object and ensure every field is included in Equatable props.

Can I use context.watch inside a button callback in flutter_bloc?

No, context.watch is only valid inside build methods. In callbacks such as onPressed, use context.read<T>() to access the bloc and dispatch events or call cubit methods.