Skip to content
Back to skills

Flutter State Management

ASecurity

Chooses between Riverpod and Bloc for a Flutter feature, implements it cleanly and covers the logic and widgets with tests.

  • 3 stars
  • 0 votes
  • 0 copies
  • 3 views
  • Added November 15, 2026
ai-agents

Security analysis

A100/100

Scanned November 15, 2026

npx -y skills add workspace-templates/ai-agent-templates --skill flutter-state-management --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Flutter State Management?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Flutter State Management
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/workspace-templates-flutter-state-management/badge)](https://www.skillsdirectory.com/skills/workspace-templates-flutter-state-management)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: flutter-state-management
description: Chooses between Riverpod and Bloc for a Flutter feature, implements it cleanly and covers the logic and widgets with tests.
---

# Flutter state management

Follow the project's existing choice. Introduce a second state library only if the user asks.

## Steps

1. Read `pubspec.yaml` and two existing features. Note which of `flutter_riverpod`, `flutter_bloc`, `provider` is in use and how files are laid out.
2. If nothing is in use, choose by need. Riverpod fits derived and cached async data, dependency injection and many small independent states. Bloc fits event-driven flows with strict transitions, such as multi-step forms, auth and payments, where an event log is valuable. Say which you chose and why in two sentences.
3. Model state as an immutable type with explicit cases: initial, loading, data, failure. Use a sealed class or freezed. Never a bag of nullable fields plus a boolean `isLoading`.
4. Riverpod: use `AsyncNotifier` or `Notifier`, read with `ref.watch` in `build`, use `ref.read` only in callbacks, and use `select` to narrow rebuilds. Bloc: one event class per user intent, one `on<Event>` handler each, emit only from handlers, and close subscriptions in `close()`.
5. Keep widgets thin. They render state and send events or call notifier methods. No repository calls, no `BuildContext` inside logic.
6. Tests: unit test the notifier with a `ProviderContainer` and overrides, or the bloc with `bloc_test`. Add widget tests that pump each state and check the visible result.
7. Run `dart format`, `flutter analyze` and `flutter test`.

## Rules

- Dispose controllers and cancel streams.
- Never call `notifyListeners` or emit after dispose.
- No global mutable singletons for state.

## Report

The library chosen and the reason, files added or changed, and test results.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.