hooks_riverpod 0.12.1
hooks_riverpod: ^0.12.1 copied to clipboard
A simple way to access state from anywhere in your application while robust and testable.
0.12.1 #
- Fixed an remaining memory leak related to StreamProvider (see also https://github.com/rrousselGit/river_pod/issues/193)
0.12.0 #
- Breaking FutureProvider and StreamProvider no-longer supports
nullas a valid value. - Fixed a memory leak with StreamProvider (see also https://github.com/rrousselGit/river_pod/issues/193)
- Fixed an error message typo related to Consumer
0.11.2 #
- Fixed a bug where providers (usually ScopedProviders) did not dispose correctly (see also https://github.com/rrousselGit/river_pod/issues/154).
0.11.1 #
- Fixed a bug where hot-reload did not work for
ConsumerWidget/Consumer
0.11.0 #
package:hooks_riverpod/hooks_riverpod.dartnow exportsStateNotifier- Marked the providers with
@sealedso that the IDE warns against implementing/subclassing providers. - Fix mistakes in
AsyncValue.guard's documentation (thanks @mono0926) - Loosened the version constraints of
freezed_annotationto support0.12.0
0.10.1 #
- Fixed invalid version error
0.10.0 #
-
Fixed a bug where the state of a provider may be disposed when it shouldn't be disposed.
-
Added a way to import the implementation class of providers with modifiers, such as
AutoDisposeProvider.This is useful if you want to use Riverpod with the lint
always_specify_types:import 'package:hooks_riverpod/all.dart'; final AutoDisposeStateProvider<int> counter = StateProvider.autoDispose<int>((ProviderReference ref) { return 0; });If you do not use this lint, prefer using the default import instead, to not pollute your auto-complete.
0.9.2 #
- Unexported some classes that were not meant to be public
0.9.0 #
- Breaking Updating
ProviderListenerso thatonChangereceives theBuildContextas parameter (thanks to @tbm98)
0.8.0 #
- Renamed
ProviderContainer.debugProviderStatestoProviderContainer.debugProviderElements - Fixed a bug where updating
ProviderScope.overridesmay cause an exception for no reason (see https://github.com/rrousselGit/river_pod/issues/107)
0.7.2 #
Fixed a bug that prevented the use of ConsumerWidget under normal circumstances
0.7.1 #
- Fixed a bug where in release mode,
ScopedProviderdid not update correctly (https://github.com/rrousselGit/river_pod/issues/101)
0.7.0 #
-
Breaking:
Consumeris slightly modified to match other Builders likeValueListenableBuilder. Before:return Consumer((context, watch) { final value = watch(myProvider); return Text('$value'); });after:
return Consumer( builder: (context, watch, child) { final value = watch(myProvider); return Text('$value'); }, ); -
Added a
ConsumerWidgetclass which can be extended to make aStatelessWidgetthat can read providers:class MyWidget extends ConsumerWidget { const MyWidget({Key key}) : super(key: key); @override Widget build(BuildContext context, ScopedReader watch) { final value = watch(myProvider); return Text('$value'); } } -
ref.watchon non ".autoDispose" providers can no-longer read ".autoDispose" providers.For more info, see http://riverpod.dev/docs/concepts/modifiers/auto_dispose#the-argument-type-autodisposeprovider-cant-be-assigned-to-the-parameter-type-alwaysaliveproviderbase
-
ScopedProvidernow acceptsnullas a function:final example = ScopedProvider<int>(null);Which is equivalent to:
final example = ScopedProvider<int>((watch) => throw UnimplementedError(''));
- Fixed a bug where
context.refreshmay not work properly if the widget tree contains multipleProviderScope.
0.6.1 #
- Fixed a bug where when disposing
ProviderContainer, providers may be disposed in an incorrect order. - Improved the performances of reading providers by 25%
0.6.0 #
-
Merged
ComputedandProvider. Now, all providers have the ability to rebuild their state when one of the object they listen changed.To migrate, change:
final provider = Provider(...); final example = Computed((watch) { final value = watch(provider); return value; });into:
final provider = Provider(...); final example = Provider((ref) { final value = ref.watch(provider); return value; }); -
Computed(nowProvider) no-longer deeply compare collections to avoid rebuilds. Comparing the content of lists is quite expensive and actually rarely useful. Now, a simple==comparison is used. -
Renamed
ProviderStateOwnertoProviderContainer -
Renamed
ProviderStateOwnerObservertoProviderObserver -
It is no-longer possible to override a provider anywhere in the widget tree. Providers can only be overriden in the top-most
ProviderScope/ProviderContainer. -
Providers can now read values which may change over time using
ref.readandref.watch. When usingref.watch, if the value obtained changes, this will cause the provider to re-create its state. -
It is no-longer possible to add
ProviderObserveranywhere in the widget tree. They can be added only on the top-mostProviderScope/ProviderContainer. -
Provider.read(BuildContext)is changed intocontext.read(provider), and can now readProvider.autoDispose. -
Added
ProviderContainer.refresh(provider)andcontext.refresh(provider). These method allows forcing the refresh of a provider, which can be useful for things like "retry on error" or "pull to refresh".
-
ref.read(StreamProvider<T>)no-longer returns aStream<T>but anAsyncValue<T>Before:final streamProvider = StreamProvider<T>(...); final example = Provider((ref) { Stream<T> stream = ref.read(streamProvider); });After:
final streamProvider = StreamProvider<T>(...); final example = Provider((ref) { Stream<T> stream = ref.watch(streamProvider.steam); }); -
ref.read(FutureProvider<T>)no-longer returns aFuture<T>but anAsyncValue<T>Before:
final futureProvider = FutureProvider<T>(...); final example = Provider((ref) { Future<T> future = ref.read(futureProvider); });After:
final futureProvider = FutureProvider<T>(...); final example = Provider((ref) { Future<T> future = ref.watch(futureProvider.future); }); -
Removed
ref.dependOn. You can now useref.read/ref.watchto acheive the same effect.Before:
final streamProvider = StreamProvider<T>(...); final example = Provider((ref) { Future<T> last = ref.dependOn(streamProvider).last; });After:
final streamProvider = StreamProvider<T>(...); final example = Provider((ref) { Future<T> last = ref.watch(streamProvider.last); }); -
Provider.readOwner(ProviderStateOwner)is changed intoProviderContainer.read(Provider) -
Provider.watchOwner(ProviderStateOwner, (value) {})is changed into:ProviderContainer container; final provider = Provider((ref) => 0); final subscription = container.listen( provider, mayHaveChanged: (sub) {}, didChange: (sub) {}. ); subscription.close(); -
MyProvider.family.autoDisposenow correctly free both the arguments and the associated providers from memory when the provider is no-longer listened.
-
Added
ScopedProvider, a new kind of provider that can be overriden anywhere in the widget tree. Normal providers cannot read aScopedProvider. -
Added
ProviderListener, a widget which allows listening to a provider without rebuilding the widget-tree. This can be useful for showing modals and pushing routes.
0.5.1 #
- Fixed the documentation of
StateNotifierProviderincorrectly showing the documentation ofStreamProvider. - Improve the documentation of
StateProvider.
0.5.0 #
- Changed
ComputedFamilyintoComputed.family - Added [AsyncValue.guard](https://pub.dev/documentation/riverpod/latest/all/AsyncValue/guard.html to simplify transforming a Future into an AsyncValue.
- Improved the documentation of the different providers
0.4.0 #
Changed the syntax of "AutoDispose*" and "*Family" to use a syntax similar to named constructors instead.
Before:
final myProvider = AutoDisposeStateNotifierProviderFamily<MyStateNotifier, int>((ref, id) {
return MyStateNotifier(id: id);
});
After:
final myProvider = StateNotifierProvider.autoDispose.family<MyStateNotifier, int>((ref, id) {
return MyStateNotifier(id: id);
});
The behavior is the same. Only the syntax changed.
0.3.1 #
- Loosen the version constraint of
flutter_hooksused to support latest versions.
0.3.0 #
-
Added
AsyncValue.whenData, syntax sugar forAsyncValue.whento handle only thedatacase and do nothing for the error/loading cases. -
Fixed a bug that caused [Computed] to crash if it stopped being listened then was listened again.
0.2.1 #
-
useProviderno longer throws anUnsupportedErrorwhen the provider listened changes, and correctly listen to the new provider. -
ComputedandConsumernow correctly unsubscribe to a provider when their function stops using a provider.
0.2.0 #
ref.readis renamed asref.dependOn- Deprecated
ref.dependOn(streamProvider).streamandref.dependOn(futureProvider).futurein favor of a universalref.dependOn(provider).value. - added
ref.read(provider), syntax sugar forref.dependOn(provider).value.
0.1.0 #
Initial release