Skip to content
Back to skills

Flutter State

ASecurity

State management and app architecture in Flutter (BLoC, Riverpod, Provider and others). Use when adding state, data loading, repositories or business logic to a Flutter app.

  • 2 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added December 2, 2026
ai-agentsapi

Works with

  • cli
  • api

Security analysis

A100/100

Scanned December 2, 2026

npx -y skills add kinleyrabgay/coxswain --skill flutter-state --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Flutter State?

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

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

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
description: State management and app architecture in Flutter (BLoC, Riverpod, Provider and others). Use when adding state, data loading, repositories or business logic to a Flutter app.
---
# State management in Flutter

## Use what the app already uses
- Detect it from `pubspec.yaml` and existing code: `flutter_bloc`, `riverpod`/`hooks_riverpod`, `provider`, `get_it`, `mobx`, `signals`. Follow the same patterns and folder layout. Never add a second approach.

## Layers
- **UI** widgets render state and send events/intents. No API calls or parsing in widgets.
- **State holders** (Bloc/Cubit, Notifier, ChangeNotifier) own screen state and call repositories.
- **Repositories** wrap data sources (HTTP, local DB, platform). They return domain models, not raw JSON.
- Models are immutable (`freezed`/`equatable` if the project uses them) with `copyWith`.

## Patterns by library
- **BLoC**: one event per user intent; states are immutable and exhaustive (initial, loading, success, failure). Use `buildWhen`/`listenWhen` to limit rebuilds; side effects (navigation, snackbars) in `BlocListener`.
- **Riverpod**: `Notifier`/`AsyncNotifier` for mutable state, `FutureProvider` for reads; `ref.watch` in build, `ref.read` in callbacks; use `.select` to narrow rebuilds; `autoDispose` for screen-scoped state.
- **Provider**: `ChangeNotifier` with `notifyListeners` after each change; `context.select` to narrow rebuilds.

## Async and errors
- Represent loading/error explicitly (`AsyncValue`, sealed states). Errors carry a user-facing message and are logged.
- Cancel subscriptions and timers on dispose. Guard against using `context` after `await` (`if (!context.mounted) return;`).

## Tests
- Unit-test state holders with mocked repositories (`bloc_test`, `ProviderContainer` overrides, or mocktail).

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.