flutter-widget-local-state-heuristics

Distinguishes ephemeral Flutter widget state from ModuleScope-owned state.

Updated Nov 7, 2025
One-click install
npx skills add https://github.com/belluga/delphi-ai --skill flutter-widget-local-state-heuristics
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: flutter-widget-local-state-heuristics
Source: https://github.com/belluga/delphi-ai/tree/main/.cline/skills/flutter-widget-local-state-heuristics
Command: npx skills add https://github.com/belluga/delphi-ai --skill flutter-widget-local-state-heuristics

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Flutter widget development often suffers from unclear boundaries between ephemeral UI state (local to a widget) and persistent state that should be owned by a module controller. This Skill provides a clear heuristics to enforce clean separation, reducing bugs caused by accidental state leakage and improving testability.

Core Features & Use Cases

  • Ephemeral UI state guidance: allow setState only for UI-only toggles and transient visuals.
  • ModuleScope/state ownership: require a controller to own non-UI state and to coordinate between widgets.
  • Enforcement strategies: recommends using a Controller + StreamValue; avoid putting module-scoped state inside presentation widgets.

Quick Start

Wrap module-scoped state in a controller and use setState only for ephemeral UI state.

Frequently Asked Questions about flutter-widget-local-state-heuristics

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I separate ephemeral Flutter widget state from persistent module state?

To separate ephemeral Flutter widget state from persistent module state, use setState only for transient UI toggles and visuals, while wrapping module-scoped state in a controller to coordinate non-UI data across widgets.

When should I avoid using setState in a Flutter StatefulWidget?

You should avoid using setState in a Flutter StatefulWidget when managing persistent, shared, or domain-related state, as this state belongs in a ModuleScope controller rather than leaking into presentation widgets.

What is the best way to manage module-scoped state in Flutter without state leakage?

The best way to manage module-scoped state in Flutter without state leakage is implementing a Controller + StreamValue approach, establishing strict boundaries that keep domain state out of presentation widgets.

Why does my Flutter module controller state disappear when rebuilding widgets?

Flutter module controller state disappears during widget rebuilds when domain state is incorrectly stored in the local widget using setState instead of being owned and persisted by the module controller.

Do I need a controller for every Flutter StatefulWidget with local UI state?

No, you do not need a controller for every Flutter StatefulWidget with local UI state; setState is appropriate and recommended for ephemeral UI-only toggles and transient visuals that do not require module-level persistence.