Upgrading flutter_riverpod 0.14 to 1
Breaking0.14.0+3 → 1.0.4Breaking17Platform1Deprecated6New19Changed9Fixed19Other1
BreakingUpgrade verdict
16 breaking changes and a platform requirement change.
In plain terms
- Two debugging helpers on the provider container are gone. Use the new single method to list provider elements.
- The mounted flag is gone, so track disposal yourself with a local variable and onDispose.
- A method that observers could override no longer exists.
- ScopedProvider no longer exists, so switch those to regular providers.
Must act Top 5 of 22 that need code or config changes
Dart SDK requirement changed in 1.0.0: >=2.12.0-0 <3.0.0 → >=2.14.0 <3.0.0.
Flutter requirement changed in 1.0.4: >=1.17.0 → >=3.0.0.
What you must change
Breaking16
Removes ProviderContainer.debugProviderValues and ProviderContainer.debugProviderElements; use ProviderContainer.getAllProviderElements instead.
ProviderContainer.debugProviderValuesProviderContainer.debugProviderElementsProviderContainer.getAllProviderElementsProviderReference.mounted is removed; use onDispose to track disposal instead.
ProviderReference.mountedonDisposeProviderObserver.mayHaveChanged is removed.
ProviderObserver.mayHaveChangedScopedProvider is removed; use Provider instead.
ScopedProviderProviderAsyncValue.copyWith is removed.
AsyncValue.copyWithUsing ref.watch or ref.read inside a selector is no longer allowed.
ref.watchref.readselectRemoves all overrideWithProvider methods; use overrideWithValue instead.
overrideWithProvideroverrideWithValueRenames ProviderBase.recreateShouldNotify to updateShouldNotify.
ProviderBase.recreateShouldNotifyupdateShouldNotifyReading a StateProvider now returns its state instead of the StateController; use ref.read(someStateProvider.state) for the old behavior.
StateProviderStateControllerref.readAll providers now receive a custom subclass of ProviderRefBase as a parameter.
ProviderRefBaseProviderRefFutureProviderRefStateProviderRefProviderFutureProviderStreamProviderref.stateStateProviderref.controllerStateControllerstatecontrollerChanges the prototype of ConsumerWidget.build and Consumer.builder to receive a WidgetRef instead of ScopedReader.
ConsumerWidgetConsumerScopedReaderWidgetRefref.watchProviderObserver.didUpdateProvider now receives both the previous and new value.
ProviderObserver.didUpdateProviderFamily.overrideWithProvider now must create a provider.
Family.overrideWithProviderProvider.familyAsyncValue.error now takes stacktrace as a named parameter instead of positional.
AsyncValue.errorAsyncValue.when loading and error callbacks (and when variants) now receive an extra previous parameter.
AsyncValue.whenChanges Family.overrideWithProvider so it must create a provider.
Family.overrideWithProviderProvider.familyPlatform1
Increases the minimum Dart SDK version to 2.14.0.
Deprecations to plan for
Deprecated5
Deprecates ProviderListener in favor of ref.listen.
ProviderListenerref.listenDeprecates StreamProvider.last in favor of StreamProvider.future.
StreamProvider.lastStreamProvider.futureDeprecates ProviderReference in favor of Ref.
ProviderReferenceRefAsyncValue.data is deprecated in favor of AsyncValue.value.
AsyncValue.dataAsyncValue.valueDeprecates ProviderReference in favor of ProviderRefBase.
ProviderReferenceProviderRefBase