bloc

Featured

Best practices for Bloc state management in Flutter/Dart, covering Cubit versus Bloc, event and state naming, sealed classes with Equatable, the Page/View split with BlocProvider, BlocBuilder, BlocListener, and BlocSelector. Use when writing, modifying, or reviewing code that uses package:bloc, package:flutter_bloc, or package:bloc_test.

Code & Development 161 stars 22 forks Updated yesterday MIT

Install

View on GitHub

Quality Score: 87/100

Stars 20%
74
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

# Bloc State management library for Dart and Flutter using the BLoC (Business Logic Component) pattern to separate business logic from the presentation layer. --- ## Core Standards Apply these standards to ALL Bloc/Cubit work: - **Use `blocTest()` from `package:bloc_test`** for all Bloc and Cubit tests — never raw `test()` with manual stream assertions - **Use `package:mocktail` for mocking** — never `package:mockito` - **No bloc-to-bloc direct dependencies** — blocs communicate through the UI or shared repositories - **Page/View separation** — Page provides the Bloc/Cubit via `BlocProvider`, View consumes via `BlocBuilder`/`BlocListener` - **Sealed classes for events and multi-state types** — enables exhaustive pattern matching with Dart 3 `switch` - **Equatable for all states and events** — extend `Equatable` and override `props` for value equality - **Business logic in Bloc/Cubit only** — never in widgets, pages, or views - **Single responsibility** — one Bloc/Cubit per feature concern - **Emit only after async checks** — use `emit` only inside the handler callback --- ## Cubit vs Bloc | Aspect | Cubit | Bloc | | ----------------- | ------------------------------ | --------------------------------------- | | API | Functions → `emit(state)` | Events → `on<Event>` → `emit(state)` | | Complexity | Low | Higher ...

Details

Author
VeryGoodOpenSource
Repository
VeryGoodOpenSource/vgv-ai-flutter-plugin
Created
6 months ago
Last Updated
yesterday
Language
Shell
License
MIT

Bundled in these plugins

Similar Skills

Semantically similar based on skill content — not just same category