본문으로 건너뛰기
cccskills
무료GitHub에 공개

provider

Use when setting up providers, consuming state, optimizing rebuilds, using ProxyProvider, or migrating from deprecated providers (Provider package).

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

설치 방법 보기

포함된 파일(1)

  • SKILL.md3.5 KB

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

Provider Skill

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


1. Provider Types

ProviderUse for
ProviderExposing any immutable value
ChangeNotifierProviderMutable state with ChangeNotifier
FutureProviderExposing a Future result
StreamProviderExposing a Stream
ProxyProvider / ChangeNotifierProxyProviderObjects that depend on other providers

2. Setup

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:

// 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:

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:

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:

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:

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

References

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

Use when working on accessibility, a11y, WCAG, ARIA, screen readers, keyboard nav, focus order, contrast, alt text, captions, reduced motion, or target sizes; not language/culture/device (see inclusive-design).

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

evanca/flutter-ai-rules6532026년 10월 10일 업데이트

Use when creating a feature, designing folder structure, adding repositories/services/view models, wiring dependency injection, or deciding which layer owns logic.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

evanca/flutter-ai-rules6532026년 10월 10일 업데이트

bloc

무료

Use when creating a Cubit or Bloc, modeling state with sealed classes or status enums, wiring BlocBuilder/BlocListener/BlocProvider, writing bloc tests, or choosing between Cubit and Bloc.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

evanca/flutter-ai-rules6532026년 10월 10일 업데이트

Use when asked to review a PR, MR, branch, or diff, audit changed files, or check code quality.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

evanca/flutter-ai-rules6532026년 10월 10일 업데이트

Use when writing switch statements, refactoring if-else chains, creating data classes, choosing records vs classes, destructuring values, or modernizing pre-Dart-3 code.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

evanca/flutter-ai-rules6532026년 10월 10일 업데이트

Use when building AI agents in Dart, implementing Genkit flows or tools, integrating LLMs into Dart or Flutter applications, or using Genkit Dart plugins.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

evanca/flutter-ai-rules6532026년 10월 10일 업데이트

evanca의 스킬 모두 보기

이 스킬의 문제 신고