skills/flutter-bloc-state-manager/SKILL.md
Flutter state management expert with BLoC/Cubit, Riverpod, Provider, and Navigation 2.0 (GoRouter). Activate on: Flutter state management, BLoC pattern, Cubit, Riverpod, Provider, GetX, GoRouter, Flutter navigation, flutter_bloc. NOT for: React Native (use react-native-architect), SwiftUI (use swiftui-data-flow-expert), Jetpack Compose (use jetpack-compose-navigation-expert).
npx skillsauth add curiositech/windags-skills flutter-bloc-state-managerInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Expert in Flutter state management with BLoC/Cubit, Riverpod, GoRouter navigation, and scalable architecture patterns.
1. State Complexity Assessment:
├─ Simple data (boolean, enum, single value)
│ └─ Use: Cubit with copyWith pattern
├─ Event-driven logic (debounce, side effects, audit trail)
│ └─ Use: BLoC with events/states
├─ Global app state with DI
│ └─ Use: Riverpod StateNotifier
└─ Widget-scoped state only
└─ Use: Provider or setState
2. When choosing between BLoC packages:
├─ Need testing/debugging tools + state/event separation
│ └─ flutter_bloc
├─ Want compile-time safety + automatic disposal
│ └─ Riverpod
├─ Legacy codebase migration
│ └─ Provider (then migrate to Cubit)
└─ Simple state only
└─ Cubit (via flutter_bloc)
3. Navigation Architecture Decision:
├─ Deep linking required OR type safety needed
│ └─ GoRouter
├─ Nested navigation with bottom tabs
│ └─ GoRouter with StatefulShellRoute
├─ Simple push/pop navigation only
│ └─ Navigator.push (but prefer GoRouter for consistency)
└─ Web app with URL routing
└─ GoRouter (required)
| Scenario | Cubit | BLoC | Riverpod | Provider | |----------|-------|------|----------|----------| | Form validation | ✅ | ❌ | ✅ | ❌ | | API loading states | ✅ | ⚠️ | ✅ | ⚠️ | | Event sourcing needed | ❌ | ✅ | ❌ | ❌ | | Global auth state | ⚠️ | ⚠️ | ✅ | ❌ | | Widget-only state | ❌ | ❌ | ❌ | ✅ |
emit(state.someList.add(item)) or direct property assignmentcopyWith and return new instances; never mutate existing state objectsScenario: Build shopping cart with add/remove items, quantity updates, price calculations, and checkout navigation.
1. State Design (Expert catches: immutability, separation of concerns)
// Novice: Single cart state with mutable list
// Expert: Immutable state with calculated properties
class CartState extends Equatable {
final Map<String, CartItem> items; // Expert: Use Map for O(1) lookups
final CartStatus status;
// Expert: Calculated properties prevent state inconsistency
double get totalPrice => items.values.fold(0, (sum, item) => sum + item.total);
int get itemCount => items.values.fold(0, (sum, item) => sum + item.quantity);
CartState copyWith({Map<String, CartItem>? items, CartStatus? status}) {
return CartState._(items ?? this.items, status ?? this.status);
}
}
2. Decision Point Navigation: Adding item logic
3. Implementation (Expert catches: performance, error handling)
class CartCubit extends Cubit<CartState> {
Future<void> addItem(Product product, int quantity) async {
final currentItems = Map<String, CartItem>.from(state.items);
final existingItem = currentItems[product.id];
if (existingItem != null) {
// Expert: Immutable update of nested object
currentItems[product.id] = existingItem.copyWith(
quantity: existingItem.quantity + quantity
);
} else {
currentItems[product.id] = CartItem.fromProduct(product, quantity);
}
emit(state.copyWith(items: currentItems));
// Expert: Navigation coupling - delegate to router
if (state.itemCount == 1) {
context.go('/cart-overview'); // First item added
}
}
}
4. What Novice Misses vs Expert Catches:
state.items.add() → UI won't rebuildbuild() methodThis skill should NOT be used for:
react-native-architect insteadswiftui-data-flow-expert insteadjetpack-compose-navigation-expert insteadflutter-ui-specialist insteadapi-architect insteaddatabase-architect insteadsetState insteadDelegate to other skills when:
mobile-offline-sync-architectflutter-performance-expertfrontend-architecttools
Building resilient distributed systems with circuit breakers, retries with full-jitter exponential backoff, retry budgets (per-request 3-attempt + per-client 10% ratio per Google SRE), deadline propagation, and the cascading-failure math (4 layers × 3 retries = 64x amplification). Grounded in Resilience4j, Microsoft Cloud Patterns, AWS Architecture Blog (Marc Brooker), and Google SRE Book.
testing
Designing HTTP cache headers that work correctly across browsers, CDNs, and shared proxies — `Cache-Control` directives per RFC 9111, `stale-while-revalidate` and `stale-if-error` per RFC 5861, the Vary header for varying responses, and surrogate keys for tag-based purging. Grounded in IETF RFCs and Cloudflare/Fastly docs.
development
Use when designing or fixing a Content Security Policy on a real site, choosing between nonce-based and hash-based CSP, adding strict-dynamic, debugging "Refused to execute inline script" errors, deploying CSP in report-only mode first, configuring report-to / report-uri, or auditing an existing policy for unsafe-inline / unsafe-eval / wildcards. Triggers: "CSP blocks legitimate inline script", strict-dynamic, nonce-{RANDOM}, sha256-{HASH}, object-src none, base-uri none, frame-ancestors, Trusted Types, X-Content-Security-Policy obsolete, report-only vs enforced. NOT for general HTTP security headers (HSTS, COOP/COEP), Trusted Types deep dive, CORS configuration, or building a WAF.
tools
Choosing and operating an HTTP API versioning strategy that doesn't break clients — Stripe's date-based pinned versions, the Deprecation/Sunset header pair (RFC 9745 + RFC 8594), URI vs header vs media-type approaches, and the version-transformer pattern. Grounded in Stripe's published architecture and IETF RFCs.