mcpField
F
flutter-state-management

flutter-state-management

github.com/thienqoDevelopment17102 installsUpdated 1d ago
Repository

About flutter-state-management

A Flutter state-management skill for developers deciding how application data is owned, changed, observed, and disposed. It emphasizes local state, explicit transitions, immutable views, and matching state patterns to project needs rather than popularity.

Key features

  1. 01Classify state by scope and lifetime
  2. 02Keep state close to its consumers
  3. 03Use a single source of truth
  4. 04Model loading and failure states
  5. 05Limit subscriptions and rebuilds
  6. 06Test transitions and disposal

Use cases

  1. 01Choosing state patterns for a Flutter project
  2. 02Refactoring unclear state ownership
  3. 03Reducing unrelated widget rebuilds
  4. 04Testing UI responses to state changes

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/thienqo/flutter-skills --skill flutter-state-management

After installing, type/flutter-state-managementin Claude Code to confirm it loaded.

Bundled filesreferences/async-state-patterns.mdreferences/lifecycle-and-disposal.md

Details

From the project README

Flutter State Management

Start with ownership and lifetime, then choose mechanics.

Inspect

Identify which state is ephemeral UI state, feature state, shared application state, cached server data, or persisted data. Determine who creates, mutates, observes, and disposes it.

Rules

  • Keep state as local as its consumers allow.
  • Maintain a single source of truth and derive secondary values instead of synchronizing copies.
  • Make state transitions explicit and keep side effects outside widget build methods.
  • Preserve an established package and its conventions when they are functioning.
  • For a new project, choose based on complexity, team familiarity, testability, code generation tolerance, and lifecycle needs—not popularity alone.
  • Expose immutable state or read-only views of mutable collections.
  • Model loading, empty, success, and failure states deliberately where the UI distinguishes them.
  • Avoid broad subscriptions that rebuild unrelated subtrees.
  • Use the package's watch-style accessor (ref.watch, context.watch<T>(), BlocBuilder) only inside build or another watch-safe method, and its one-off accessor (ref.read, context.read<T>(), a Bloc's add) inside callbacks and event handlers. Calling the watch-style accessor from a callback throws or misbehaves in most packages.

Do not introduce global service locators or package-level singletons as a shortcut for unclear ownership.

Verification

Test meaningful transitions, failure recovery, disposal, and repeated events. Inspect rebuild scope for hot paths and run widget tests for state-to-UI behavior.

Boundaries

Architecture-wide dependency direction belongs to flutter-architecture; persistence and remote caching belong to their data specialists.

When disposal behavior or lifecycle leaks are in scope, follow the lifecycle and disposal reference. For async state modeling and error recovery, follow the async state patterns reference.

Sources

Comments

Markdown supported