Skip to main content
skill CX Codex

provider · evanca — Claude Code skill: what it does, how to install

Guides agents on architecting Flutter state with the provider package, keeping rebuilds minimal and dependencies reactive.

MIT ★ 674 updated 2026-10-29

Install into Claude Code · Plugin marketplace All methods and platforms ↓
/plugin marketplace add evanca/flutter-ai-rules
/plugin install flutter-ai-skills@flutter-ai-rules
Open on GitHub

What provider does

This skill instructs coding assistants on best practices for the Flutter provider package. It guides the model to select suitable primitives such as ChangeNotifierProvider, StreamProvider, or FutureProvider, bundling them cleanly with MultiProvider.

The guidance enforces clear boundaries for reading state: context.watch stays confined to build methods, while events and callbacks trigger logic strictly via context.read. For selective UI updates, it directs the agent toward context.select, Consumer, and Selector.

Instantiating a provider from values that change over time causes stale states, so the skill mandates ProxyProvider whenever dependencies shift. It also notes that mounting over 150+ providers at once risks a StackOverflowError, advising staged initialization instead.

What it helps with

  • Wire dependent models together using ProxyProvider without stale data
  • Cut down unnecessary UI rebuilds via Selector and context.select
  • Migrate away from deprecated ValueListenableProvider
  • Prevent runtime crashes by keeping provider reads out of initState

Example prompts for the agent

  • Set up an authentication service and dependent API client using ProxyProvider
  • Refactor this screen to consume updates through context.select instead of full rebuilds
  • Migrate deprecated listener providers to ValueListenableBuilder with Provider.value

How to install provider

1Plugin marketplace

/plugin marketplace add evanca/flutter-ai-rules
/plugin install flutter-ai-skills@flutter-ai-rules

This installs the whole flutter-ai-skills plugin with all its skills

2Skills CLI (Vercel)

npx skills add evanca/flutter-ai-rules --skill provider -a claude-code

3Manually: put the files in place

~/.claude/skills/provider/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/provider/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about provider

How to install provider in Claude Code?

Run both commands in order: /plugin marketplace add evanca/flutter-ai-rules followed by /plugin install flutter-ai-skills@flutter-ai-rules.

What does the provider skill do?

It guides AI tools to generate correct Flutter code with provider, enforcing clean rebuild patterns and proper dependency resolution.

Can providers be accessed inside initState?

No, the skill explicitly bans calling providers inside initState or constructors because the widget tree is not fully mounted yet.

Source text

SKILL.md · MIT
---
name: provider
description: "Use when setting up providers, consuming state, optimizing rebuilds, using ProxyProvider, or migrating from deprecated providers (Provider package)."
license: MIT
---

# Provider Skill

This skill defines how to correctly use the `provider` package in Flutter applications.

---

## 1. Provider Types

| Provider | Use for |
|---|---|
| `Provider` | Exposing any immutable value |
| `ChangeNotifierProvider` | Mutable state with `ChangeNotifier` |
| `FutureProvider` | Exposing a `Future` result |
| `StreamProvider` | Exposing a `Stream` |
| `ProxyProvider` / `ChangeNotifierProxyProvider` | Objects that depend on other providers |

---

## 2. Setup

```dart
MultiProvider(
  providers: [
    Provider<Something>(create: (_) => Something()),
    ChangeNotifierProvider(create: (_) => MyNotifier()),
    FutureProvider<String>(create: (_) => fetchData(), initialData: ''),
  ],
  child: MyApp(),
)
```

- Use `MultiProvider` to group multiple providers and avoid deeply nested trees.
- `ChangeNotifierProvider` **automatically disposes** the model when it is no longer needed.
- **Never** create a provider's object from variables that can change over time — the object won't update when the variable changes. Use `ProxyProvider` instead.
- If you have 150+ providers, consider mounting them over time (e.g., during a splash screen) rather than all at once to avoid `StackOverflowError`.

---

## 3. Consuming State

Always specify the **generic type** for type safety:

```dart
// Listen and rebuild on change — only valid inside build() or a Provider's update method
final count = context.watch<MyModel>().count;

// Access without listening — use in callbacks, not inside build()
context.read<MyModel>().increment();

// Listen to only part of the state
final count = context.select<MyModel, int>((m) => m.count);
```

Use `Consumer<T>` or `Selector<T, R>` widgets when you need fine-grained rebuilds and cannot access a descendant `BuildContext`:

```dart
Consumer<MyModel>(
  builder: (context, model, child) => Text('${model.count}'),
  child: const ExpensiveWidget(), // rebuilt only once
)

Selector<MyModel, int>(
  selector: (_, model) => model.count,
  builder: (_, count, __) => Text('$count'),
)
```

---

## 4. ProxyProvider

Use `ProxyProvider` or `ChangeNotifierProxyProvider` for objects that depend on other providers or values that can change:

```dart
MultiProvider(
  providers: [
    Provider<Auth>(create: (_) => Auth()),
    ProxyProvider<Auth, Api>(
      update: (_, auth, __) => Api(auth.token),
    ),
  ],
)
```

---

## 5. Rules

- Do **not** access providers inside `initState` or constructors — use them in `build`, callbacks, or lifecycle methods where the widget is fully mounted.
- You can use **any object** as state, not just `ChangeNotifier`; use `Provider.value()` with a `StatefulWidget` if needed.

---

## 6. Debugging

Implement `toString` or `DiagnosticableTreeMixin` to improve how your objects appear in Flutter DevTools:

```dart
class MyModel with DiagnosticableTreeMixin {
  final int count;
  MyModel(this.count);

  @override
  String toString() => 'MyModel(count: $count)';
}
```

---

## 7. Migration: ValueListenableProvider

`ValueListenableProvider` is deprecated. Use `Provider` with `ValueListenableBuilder` instead:

```dart
ValueListenableBuilder<int>(
  valueListenable: myValueListenable,
  builder: (context, value, _) {
    return Provider<int>.value(
      value: value,
      child: MyApp(),
    );
  },
)
```

---

## References

- [Provider GitHub Repository](https://github.com/rrousselGit/provider)

© Ivanna Kaceviča · MIT · evanca/flutter-ai-rules

Similar skills

All skills for Mobile →

provider by other authors comes first.

From the same set39

The whole set →
code_review The code_review rule for Claude Code sets a review process for changes before merging. It checks branches, files, code, tests, and the PR/MR description. CX Codex +1 ★ 674repo stars flutter-errors flutter-errors is a Claude Code skill that helps diagnose Flutter layout and runtime errors. It activates for RenderFlex overflow, scroll issues, and setState calls during build. CX Codex +1 ★ 674repo stars mocktail Guidance for using Mocktail in Dart and Flutter tests: configure stubs, inspect interactions, and decide when a mock, fake, or real object fits. CX Codex +1 ★ 674repo stars flutter-change-notifier flutter-change-notifier — a skill that teaches the agent to use ChangeNotifier and provider for Flutter state management: models, providers, Consumer, rebuild optimization. CX Codex +1 ★ 674repo stars mockito mockito is a Claude Code skill for Dart and Flutter tests that guides mock generation, stubbing, and interaction checks. It activates for Mockito testing tasks. CX Codex +1 ★ 674repo stars developing-genkit-dart developing-genkit-dart — a skill for building AI agents with Genkit Dart that tells the agent when to pull in reference docs for the core framework and its plugins. CX Codex +1 ★ 674repo stars firebase-storage firebase-storage is a skill with guidelines for Firebase Cloud Storage in Flutter apps, covering file uploads, downloads, metadata changes, and storage error handling. CX Codex +1 ★ 674repo stars firebase-data-connect Get guidance for Firebase Data Connect in Flutter, from GraphQL operations and typed SDK generation to access rules and offline handling. CX Codex +1 ★ 674repo stars

Project sponsors

Companies that keep this analytics open