managing-flutter-provider-state
Installation
SKILL.md
Provider State Management Guide (v6.x)
Goal
Implement state management and dependency injection using the provider package in Flutter applications. Provider is built on Flutter's native InheritedWidget and remains the foundation for many production apps worldwide. This guide enforces MVVM (Model-View-ViewModel) architecture patterns and eliminates unnecessary widget rebuilds through targeted state consumption.
Process
Phase 1: Understand State Scope
Before implementing Provider, determine if the state truly needs to be shared:
- Ephemeral State (local): Use
StatefulWidget+setState()for UI state confined to a single widget (e.g., form input, animation progress, current tab index). - App State (shared): Use Provider when multiple unrelated widgets need access to the same data (e.g., user auth, shopping cart, app settings).
If uncertain about the scope, ask the user to clarify the intended lifecycle and accessibility requirements.