riverpod
하는 일
이 스킬은 Riverpod 라이브러리로 Flutter 앱의 데이터와 상태를 다루는 방법을 설명합니다. 데이터를 공유하고 업데이트하는 프로바이더 방식을 원하는 개발자를 위한 스킬입니다.
사용하는 경우
- ✓여러 화면에서 데이터를 공유해야 하는 Flutter 앱을 만들 때.
- ✓서버에서 데이터를 불러와 앱에 보여 줘야 할 때.
- ✓Flutter 앱 상태의 테스트를 작성하고 싶을 때.
스킬 링크
https://github.com/andrewyng/context-hub/blob/main/content/flutter/skills/state-management/riverpod/SKILL.md복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.
사용 방법
가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.
바로 붙여넣을 수 있는 메시지
Claude Code, Codex, Cursor용입니다. 프로젝트 폴더에서 실행하면 스킬이 설치됩니다.
SKILL.md를 다운로드해 에이전트의 스킬 폴더에 넣으세요.
AI에게 요청하는 예시
“Riverpod을 사용해 서버에서 제품 목록을 불러오고, 로딩 스피너를 보여 주는 것을 도와주세요.”
매주 새 스킬 5개. 읽는 데 1분.
작동 방식
스킬은 각 종류의 데이터를 맞는 프로바이더 유형에 연결합니다. 예를 들어 한 번만 불러오는 경우나 실시간 스트림이 필요한 경우입니다. 그다음 이를 앱의 화면에 연결하는 방법을 보여 줍니다.
기술 내용 (원본 SKILL.md)
작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.
Flutter Riverpod State Management
Use this skill when building Flutter state management with riverpod and flutter_riverpod.
Core Rule
- Use
Providerfor read-only values and dependency wiring. - Use
StateProviderfor small mutable state. - Use
FutureProviderfor one-shot async loading. - Use
StreamProviderfor reactive streams. - Use
NotifierorAsyncNotifierfor feature state that needs mutation methods. - Use
autoDisposefor short-lived state. - Use
familywhen provider output depends on an argument. - Use
flutter_riverpodin Flutter apps. - If you use
flutter_riverpod, you usually do not addriverpodseparately because the Flutter package brings it in transitively. - Current stable line is Riverpod 3.x (
riverpod3.2.1,flutter_riverpod3.3.1).
Decision Guide
Choose Riverpod when:
- you want provider-based dependency injection and reactive state in one model
- state should be derived from other providers
- async data is a major part of the feature
- test overrides and scoped state matter
- you want fewer classes than a Bloc-heavy approach
Choose a different pattern when:
- the feature is a tiny local state toggle and a simple widget would be enough
- the logic is better expressed as an explicit event machine
Required Project Setup
For Dart-only code:
- add
riverpod
For Flutter UI code:
- add
flutter_riverpod - wrap the app in
ProviderScope - use
ConsumerWidget,Consumer, orConsumerStatefulWidgetwhererefis needed
If code generation is used:
- add
riverpod_annotation - add
riverpod_generator - add
build_runner
Implementation Pattern
Prefer this structure:
- providers own state, dependencies, and derived values
- repositories and APIs stay outside widgets
- UI reads state with
ref.watch - UI performs imperative reads with
ref.read - container-level overrides are used for tests, demos, and environment-specific wiring
Keep providers small and composable. Keep state immutable unless the provider type is specifically meant for mutation. Keep feature logic in providers or notifiers, not in widgets.
Lifecycle Rules
- Use
autoDisposefor short-lived screens and transient queries. - Use
ref.keepAlive()only when you want cached state to survive temporarily. - Prefer provider disposal over manual cleanup.
- In tests and pure Dart code, dispose
ProviderContainerwhen finished.
UI Binding Rules
Use ConsumerWidget when the whole widget depends on providers.
Use Consumer when only a small subtree needs access to ref.
Use ConsumerStatefulWidget when you need widget lifecycle plus ref.
Use select to reduce rebuilds.
Use ProviderListener or ref.listen for side effects.
Testing Rules
- Test providers through
ProviderContainer. - Override dependencies instead of mocking provider internals.
- Assert
AsyncValuestates directly for async providers. - Dispose containers in tests.
Common Pitfalls
- Do not call
ref.watchinside callbacks; useref.readthere. - Do not skip
ProviderScopeat the app root. - Do not use
StateProviderfor large feature state. - Do not put business logic in widgets.
- Do not rebuild the whole tree when a single field changes; use
select. - Do not model async loading manually when
FutureProviderorAsyncNotifierfits. - Do not forget provider overrides for tests and previews.
What To Prefer In Answers
When writing code or advising on design:
- show the smallest working provider first
- mention whether
ProviderScopeis required - mention whether the provider should be
autoDisposeor cached - mention whether a
familyis needed for arguments - include test override notes when dependencies are external
- keep examples aligned with the current Riverpod docs and Flutter integration patterns
- if code generation is involved, prefer matching
riverpod_annotation/riverpod_generatorversions from the same 3.x release line
Minimal Reference Checklist
ProviderScope= app root setupref.watch= rebuild on changeref.read= imperative accessselect= narrower rebuildsautoDispose= short-lived statefamily= parameterized providerProviderContainer= test/headless container
자주 묻는 질문
어떤 Riverpod 버전을 다루나요?
스킬은 현재 안정 버전 계열이 Riverpod 3.x라고 밝힙니다.
Flutter용으로 따로 패키지가 필요한가요?
Flutter 앱에는 flutter_riverpod을 쓰며, 이것이 핵심 패키지를 함께 가져옵니다.
Riverpod이 최선이 아닌 경우는 언제인가요?
스킬은 작은 로컬 토글에는 간단한 위젯만으로 충분할 수 있고, 이벤트가 많은 로직에는 Bloc이 더 맞을 수 있다고 말합니다.
상세 정보
작성자의 원본 설명
Use when working with Flutter Riverpod state management. Covers providers, consumers, refs, containers, overrides, async state, code generation, testing, and safe defaults.
repo: andrewyng/context-hub
인기도
- GitHub 스타
- 14k
- 순위
- #11270
- 라이선스
- MIT
- 업데이트
- 2026. 5. 31.
댓글
- …
이 저장소의 다른 스킬
get-api-docs
14k에이전트가 코드를 쓰기 전에, 오래된 기억 대신 서드파티 API와 라이브러리의 최신 문서를 가져오도록 돕습니다.
bloc-cubit
14k에이전트에게 Flutter 앱의 상태를 Bloc이나 Cubit으로 관리하는 방법을 가르칩니다. 각 도구를 고르는 기준과 테스트용 기본값을 포함합니다.
document-extraction
14k에이전트가 PDF, 이미지, 스프레드시트를 읽어 깨끗한 텍스트로 바꾸고, LandingAI ADE 서비스로 송장 합계 같은 항목을 뽑아내도록 돕습니다.
document-workflows
14k에이전트가 많은 문서를 일괄 처리하고, 검색용으로 준비하며, 결과를 데이터베이스에 넣는 파이프라인을 만들도록 돕습니다.
비슷한 스킬
android-clean-architecture
280k에이전트가 Android 프로젝트를 효율적으로 구성하도록 돕습니다. 유지보수와 새 기능 개발이 쉽도록 코드를 구조화합니다.
compose-multiplatform-patterns
280k에이전트가 KMP 프로젝트에서 Compose Multiplatform과 Jetpack Compose 패턴을 쓰도록 돕습니다. 상태, 내비게이션, 테마, 성능을 다룹니다.
dart-flutter-patterns
280kDart와 Flutter 앱용 코드를 작성하도록 에이전트를 돕습니다. 견고하고 관리하기 쉬운 앱을 만드는 현대적인 패턴을 씁니다.