r/FlutterDev • • Oct 01 '22

Plugin Riverpod 2.0 has been Released

https://pub.dev/packages/riverpod
107 Upvotes

12 comments sorted by

25

u/pattobrien Oct 01 '22

From the Changelog:

"A detailed changelog for the 2.0.0 stable release will be available in the coming days.
In the meantime, here is the list of changes between the 2.0.0 version and the 2.0.0-dev.9 version.
Breaking changes:
- FutureProvider.stream is removed.
- Family now has a single generic parameter instead of 3.
- Using overrideWithProvider, it is no-longer possible to override a provider with a different type of provider (such as overriding FutureProvider with a StreamProvider).
- AsyncError.stackTrace is now a required positional parameter and non-nullable
- All overrideWithValue methods are removed, besides Provider.overrideWithValue. This change is temporary, and these methods will be reintroduced in a later version.
- Modifiers (provider.future, provider.state, ...) no-longer are providers, and therefore no-longer appears inside ProviderObserver.
- The Reader typedef is removed. Use Ref instead.
- ProviderListener is removed. Used ref.listen instead.
- Providers other than FutureProvider/StreamProvider no-longer override AsyncValues to set - AsyncValue.isRefreshing when an AsyncLoading is emitted.
- It is no longer possible to pass provider.future/.notifier/... to the parameter dependencies of provider. Simply pass the provider instead.
- cacheTime/disposeDelay are no longer a Duration but instead an int, representing the - - Duration in milliseconds.

Non-breaking changes:
- feat: A new AutoDisposeRef.keepAlive() function is added. It is meant to replace AutoDisposeRef.maintainState to make logic for preventing the disposal of a provider more reusable.
- AutoDisposeRef.maintainState is deprecated. Use the new AutoDisposeRef.keepAlive() instead.
- feat: Add support for ref.invalidate(family) to recompiute an entire family (#1517)
- fixed a bug where AsyncValue.whenData did not preserve AsyncValue.isLoading/isRefreshing
- fix: StateProvider and StateNotifierProvider no longer notify their listeners on ref.refresh if the new result is identical to the old one.
- fix: potential null exception when using autoDispose"

30

u/AnserHussain Oct 02 '22

Welp, can't wait to see how much of YouTube tutorials code is deprecated, still learning (o)

3

u/zintjr Oct 02 '22

Underrated comment ☺️

2

u/utilitycoder Oct 02 '22

Everyone is "still learning"

45

u/beyonder84 Oct 01 '22

Thanks Remi for your hard work

3

u/Masahide_Mori Oct 02 '22

Riverpod is so cool!

2

u/Gold-Ninja-4160 Oct 01 '22

Can't wait to try it! Many thanks πŸ™

1

u/Edzomatic Oct 02 '22

Is the documentation on the website up to date?

-17

u/OldHummer24 Oct 01 '22 edited Oct 01 '22

Is it better than GetX now??? πŸ€”

Edit: /s 😒

-2

u/D_apps Oct 01 '22

That is a question lol