bloc

Implements Bloc and Cubit state management patterns for Flutter and Dart applications.

162|23|Updated Feb 27, 2026
One-click install
npx skills add https://github.com/VeryGoodOpenSource/vgv-ai-flutter-plugin --skill bloc-verygoodopensource
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: bloc
Source: https://github.com/VeryGoodOpenSource/vgv-ai-flutter-plugin/tree/main/skills/bloc
Command: npx skills add https://github.com/VeryGoodOpenSource/vgv-ai-flutter-plugin --skill bloc-verygoodopensource

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Flutter developers often struggle with inconsistent state management, tangled business logic in widgets, and untested Bloc/Cubit code. This Skill enforces VGV best practices for the Bloc library so your state management follows a clean, testable architecture from the start. ## Core Features & Use Cases - Cubit vs Bloc Guidance: Decision criteria for choosing Cubit or Bloc, with naming conventions for events and states using sealed classes and Equatable. - Page/View Architecture: Enforces separation where Pages provide Blocs via BlocProvider and Views consume state via BlocBuilder, BlocListener, and BlocSelector. - Testing Standards: Mandates blocTest() from package:bloc_test with package:mocktail, including mocking repositories, seeding states, and widget integration tests. - Use Case: When asked to "write tests for LoginBloc" or "add a debounced search feature", the Skill produces a Bloc with a restartable event transformer, Equatable states, and complete blocTest coverage. ## Quick Start Ask the AI to create a Bloc or Cubit for a Flutter feature, or to write blocTest unit tests for an existing Bloc class.

Frequently Asked Questions about bloc

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

FAQPage Schema
How do I test a Bloc or Cubit in Flutter?

Use blocTest() from package:bloc_test with build, act, and expect parameters to assert emitted states in order. Mock dependencies with package:mocktail, never mockito, and use seed to set an initial state before acting.

When should I use Cubit vs Bloc in Flutter?

Use Cubit for simple state and UI-driven logic where methods directly emit states. Use Bloc for complex event-driven flows that need traceability or event transformers like debounce via package:bloc_concurrency.

What is the Page/View pattern in flutter_bloc?

The Page widget creates and provides the Bloc via BlocProvider, while the View consumes state via BlocBuilder and handles side effects with BlocListener. This keeps business logic out of widgets and makes both layers independently testable.

Can one Bloc depend on another Bloc in Flutter?

No, direct bloc-to-bloc dependencies are forbidden. Blocs should communicate through the UI layer or shared repositories, keeping each Bloc scoped to a single feature concern.

How do I add debounce to a Bloc event handler?

Use an event transformer from package:bloc_concurrency, such as restartable(), passed as the transformer argument to on<Event>. This cancels in-flight processing when a new event arrives, which requires a Bloc rather than a Cubit.