LogoSkills

riverpod-migration

Migrate Riverpod from StateNotifier to Notifier/AsyncNotifier, from ChangeNotifier to AsyncNotifier, or upgrade from 0.13/0.14/1.0; ref.onDispose, family, lifecycle, riverpod migrate CLI. Use when ...

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#

ScenarioReference
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; use ref.onDispose instead of overloading dispose; no mountedโ€”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 with AsyncValue; single state; mutations by reassigning state.
  • CLI: For 0.14 and 1.0 upgrades you can run dart pub global activate riverpod_cli then riverpod migrate in 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.