Riverpod โ Migration guides#
ํ๋ง๋๋ก (๋น๊ฐ๋ฐ์์ฉ)#
์ฑ์ ํ๋ฉด ์ํ(์: ๋ก๋ฉ ์ค์ธ์ง, ๋ฐ์ดํฐ๊ฐ ์ค๋น๋๋์ง)๋ฅผ ๊ด๋ฆฌํ๋ ๋๊ตฌ๊ฐ Riverpod์ ๋๋ค. ์ด ์คํฌ์ ๊ทธ ๋๊ตฌ์ ๋ก์ ๋ฒ์ ์ ์ ๋ฒ์ ์ผ๋ก ๊ฐ์ํ๋ "์ด์ฌ ์๋ด์" ๋ชจ์์ด์์. ๋ง์น ์ค๋๋ ๊ฐ์ ์ ํ์ ์ ํ์ผ๋ก ๋ฐ๊ฟ ๋ ์ด๋ค ์ฝ๋๋ฅผ ๋ฝ๊ณ ์ด๋์ ๋ค์ ๊ฝ์์ผ ํ๋์ง ์๋ ค์ฃผ๋ ์ค๋ช ์์ ๊ฐ์ต๋๋ค. ์ํฉ๋ณ๋ก ๋ง๋ ์๋ด์๋ฅผ ๊ณจ๋ผ ๋จ๊ณ๋๋ก ๋ฐ๋ผ๊ฐ๋๋ก ๋์์ค๋๋ค.
๋ฌด์์ยท์ธ์ (๋น๊ฐ๋ฐ์์ฉ)#
- ๋ฌด์์: ์๋ ๋ฐฉ์์ผ๋ก ์ง ์ํ ๊ด๋ฆฌ ์ฝ๋๋ฅผ ์ต์ ๋ฐฉ์์ผ๋ก ์์ ํ๊ฒ ์ฎ๊ธฐ๋ ๊ธธ์ ์๋ดํฉ๋๋ค.
-
์ด๋ค ๊ฒฝ์ฐ๋ฅผ ๋ค๋ฃจ๋์:
- ์์ ๋ฐฉ์(StateNotifier)์์ ์ ๋ฐฉ์(Notifier/AsyncNotifier)์ผ๋ก ์ฎ๊ธธ ๋
- ๋ ๋ค๋ฅธ ์์ ๋ฐฉ์(ChangeNotifier)์์ ์ ๋ฐฉ์(AsyncNotifier)์ผ๋ก ์ฎ๊ธธ ๋
- ๋ฒ์ 0.13์์ 0.14๋ก, 0.14์์ 1.0์ผ๋ก ์ฌ๋ฆด ๋
- (2.0์์ 3.0์ผ๋ก ์ฌ๋ฆฌ๋ ๊ฒฝ์ฐ๋ ๋ค๋ฅธ ์คํฌ์ ์๋ดํฉ๋๋ค)
- ์ธ์ ์๋ํ๋์: ์์ ๊ฐ์ "Riverpod ๋ฒ์ ์ฌ๋ฆฌ๊ธฐ" ๋๋ "์ ๋ฐฉ์์์ ์ ๋ฐฉ์์ผ๋ก ๋ฐ๊พธ๊ธฐ"๋ฅผ ๋ฌผ์ด๋ณผ ๋ ์๋์ผ๋ก ๋์์ ์ค๋๋ค.
- ์ถ๊ฐ ๋์: ๋ฒ์ ์ฌ๋ฆฌ๊ธฐ ์์ ์ ์๋ ๋ณํ ๋๊ตฌ(CLI)๋ฅผ ์คํํด ์์ด ๋ ๊ฐ๊ฒ ์ฒ๋ฆฌํ ์๋ ์๋ค๊ณ ์๋ ค์ค๋๋ค.
ํต์ฌ ์ฉ์ด (๋น๊ฐ๋ฐ์์ฉ)#
| ์ฉ์ด | ์ฌ์ด ์ค๋ช |
|---|---|
| Riverpod | ์ฑ ํ๋ฉด์ ์ํ(๋ฐ์ดํฐ, ๋ก๋ฉ ์ฌ๋ถ ๋ฑ)๋ฅผ ์ ๋ฆฌํด ๊ด๋ฆฌํ๋ ๋๊ตฌ |
| ๋ง์ด๊ทธ๋ ์ด์ (migration) | ๋ก์ ๋ฐฉ์ยท๋ฒ์ ์์ ์ ๋ฐฉ์ยท๋ฒ์ ์ผ๋ก ๊ฐ์ํ๋ ์ด์ฌ ์์ |
| StateNotifier / Notifier / AsyncNotifier / ChangeNotifier | ์ํ๋ฅผ ๋ค๋ฃจ๋ ๋ฐฉ์๋ค. ๋ค๋ก ๊ฐ์๋ก ๋ ์๋กญ๊ณ ๊ถ์ฅ๋๋ ๋ฐฉ์ |
| AsyncValue | "๋ก๋ฉ ์ค / ์ฑ๊ณต / ์ค๋ฅ"๋ฅผ ํ ๋ฉ์ด๋ฆฌ๋ก ๊น๋ํ๊ฒ ํํํด ์ฃผ๋ ๊ฐ |
| CLI | ๋ช ๋ น์ด๋ก ์์ ์ ์๋ ์คํํ๋ ๋๊ตฌ. ์ฌ๊ธฐ์๋ ๋ฒ์ ๋ณํ์ ์๋์ผ๋ก ๊ฑฐ๋ค์ด ์ค |
| ref.onDispose | ํ๋ฉด์ด ๋ซํ ๋ ๋ท์ ๋ฆฌ(๋ฆฌ์์ค ํด์ )๋ฅผ ์๋์ผ๋ก ํด์ฃผ๋ ์ฅ์น |
Instructions#
This skill points to detailed migration guides for different scenarios. Use the reference file that matches your case.
When to use which guide#
| Scenario | Reference |
|---|---|
| From StateNotifier to Notifier / AsyncNotifier | migration_from_state_notifier.md |
| From ChangeNotifier to AsyncNotifier | migration_from_change_notifier.md |
| Upgrade 0.13.x โ 0.14.x (StateNotifierProvider syntax, watch(provider) vs provider.state) | migration_0_13_0_14.md |
| Upgrade 0.14.x โ 1.0 (ScopedReader โ WidgetRef, useProvider โ ref.watch, StateProvider) | migration_0_14_1_0.md |
For Riverpod 2.0 โ 3.0 see the riverpod-3-0-migration skill.
Common themes#
-
StateNotifier โ Notifier/AsyncNotifier: Put init logic in
build; useref.onDisposeinstead of overloadingdispose; nomountedโuse cancellation (e.g. Completer or HTTP cancel token). Consumers stay the same (ref.watch, methods on notifier). -
ChangeNotifier โ AsyncNotifier: Replace
isLoading/hasError/manual try-catch withAsyncValue; singlestate; mutations by reassigningstate. -
CLI: For 0.14 and 1.0 upgrades you can run
dart pub global activate riverpod_clithenriverpod migratein the project (do not upgrade Riverpod manually first; the tool will suggest version and changes).
Open the relevant reference file for step-by-step instructions and code examples.