Skip to content

Commit

Permalink
Fix FutureProvider<void> (#2029)
Browse files Browse the repository at this point in the history
fixes #2028
  • Loading branch information
rrousselGit committed Dec 25, 2022
1 parent 0ef70a4 commit d34d740
Show file tree
Hide file tree
Showing 13 changed files with 47 additions and 13 deletions.
4 changes: 4 additions & 0 deletions packages/flutter_riverpod/CHANGELOG.md
@@ -1,3 +1,7 @@
## 2.1.3

Fixes an issue with `FutureProvider<void>` (#2028)

## 2.1.2

- It is now correctly possible to use `ProviderSubscription`s inside `ConsumerState.dispose` (thanks to @1980)
Expand Down
4 changes: 2 additions & 2 deletions packages/flutter_riverpod/pubspec.yaml
Expand Up @@ -2,7 +2,7 @@ name: flutter_riverpod
description: >
A simple way to access state from anywhere in your application
while robust and testable.
version: 2.1.2
version: 2.1.3
homepage: https://riverpod.dev
repository: https://github.com/rrousselGit/riverpod

Expand All @@ -15,7 +15,7 @@ dependencies:
flutter:
sdk: flutter
meta: ^1.4.0
riverpod: 2.1.2
riverpod: 2.1.3
state_notifier: ^0.7.2

dev_dependencies:
Expand Down
4 changes: 4 additions & 0 deletions packages/hooks_riverpod/CHANGELOG.md
@@ -1,3 +1,7 @@
## 2.1.3

Fixes an issue with `FutureProvider<void>` (#2028)

## 2.1.2

- It is now correctly possible to use `ProviderSubscription`s inside `ConsumerState.dispose` (thanks to @1980)
Expand Down
6 changes: 3 additions & 3 deletions packages/hooks_riverpod/pubspec.yaml
Expand Up @@ -2,7 +2,7 @@ name: hooks_riverpod
description: >
A simple way to access state from anywhere in your application
while robust and testable.
version: 2.1.2
version: 2.1.3
homepage: https://riverpod.dev
repository: https://github.com/rrousselGit/riverpod

Expand All @@ -15,8 +15,8 @@ dependencies:
flutter:
sdk: flutter
flutter_hooks: ^0.18.0
flutter_riverpod: 2.1.2
riverpod: 2.1.2
flutter_riverpod: 2.1.3
riverpod: 2.1.3
state_notifier: ^0.7.2

dev_dependencies:
Expand Down
4 changes: 4 additions & 0 deletions packages/riverpod/CHANGELOG.md
@@ -1,3 +1,7 @@
## 2.1.3

Fixes an issue with `FutureProvider<void>` (#2028)

## 2.1.2

- Update dependencies.
Expand Down
2 changes: 1 addition & 1 deletion packages/riverpod/lib/src/async_notifier/base.dart
Expand Up @@ -275,7 +275,7 @@ mixin FutureHandlerProviderElementMixin<T>
required last,
}) {
final futureOr = create();
if (futureOr is T) {
if (futureOr is! Future<T>) {
data(futureOr);
done();
return null;
Expand Down
2 changes: 1 addition & 1 deletion packages/riverpod/pubspec.yaml
Expand Up @@ -2,7 +2,7 @@ name: riverpod
description: >
A simple way to access state from anywhere in your application while robust
and testable.
version: 2.1.2
version: 2.1.3
homepage: https://riverpod.dev
repository: https://github.com/rrousselGit/riverpod

Expand Down
Expand Up @@ -58,6 +58,20 @@ void main() {
});
});

test('Supports void type', () async {
// Regression test for https://github.com/rrousselGit/riverpod/issues/2028
final testProvider = FutureProvider<void>((ref) async {
return Future.value();
});

final container = createContainer();
expect(container.read(testProvider), const AsyncLoading<void>());

await container.read(testProvider.future);

expect(container.read(testProvider), const AsyncData<void>(null));
});

test('supports overrideWith', () {
final provider = FutureProvider<int>((ref) => 0);
final autoDispose = FutureProvider.autoDispose<int>((ref) => 0);
Expand Down
4 changes: 4 additions & 0 deletions packages/riverpod_annotation/CHANGELOG.md
@@ -1,3 +1,7 @@
## 1.1.1

Upgrade Riverpod to latest

## 1.1.0

Upgrade Riverpod to latest
Expand Down
4 changes: 2 additions & 2 deletions packages/riverpod_annotation/pubspec.yaml
@@ -1,13 +1,13 @@
name: riverpod_annotation
description: A package exposing annotations for riverpod_generator
version: 1.1.0
version: 1.1.1

environment:
sdk: ">=2.17.0 <3.0.0"

dependencies:
meta: ^1.7.0
riverpod: 2.1.2
riverpod: 2.1.3

dev_dependencies:
test: ^1.21.0
4 changes: 4 additions & 0 deletions packages/riverpod_generator/CHANGELOG.md
@@ -1,3 +1,7 @@
## 1.1.1

Upgrade Riverpod to latest

## 1.1.0

- The generated hash function of providers is now correctluy private (thanks to @westito)
Expand Down
2 changes: 1 addition & 1 deletion packages/riverpod_generator/pubspec.yaml
@@ -1,6 +1,6 @@
name: riverpod_generator
description: A code generator for Riverpod. This both simplifies the syntax empowers it, such as allowing stateful hot-reload.
version: 1.1.0
version: 1.1.1
repository: https://github.com/rrousselGit/riverpod

environment:
Expand Down
6 changes: 3 additions & 3 deletions website/docs/getting_started.mdx
Expand Up @@ -50,7 +50,7 @@ dependencies:
flutter:
sdk: flutter
flutter_hooks: ^0.18.0
hooks_riverpod: ^2.1.2
hooks_riverpod: ^2.1.3
```

Then run `flutter pub get`.
Expand All @@ -66,7 +66,7 @@ environment:
dependencies:
flutter:
sdk: flutter
flutter_riverpod: ^2.1.2
flutter_riverpod: ^2.1.3
```

Then run `flutter pub get`.
Expand All @@ -79,7 +79,7 @@ environment:
sdk: ">=2.12.0-0 <3.0.0"

dependencies:
riverpod: ^2.1.2
riverpod: ^2.1.3
```

Then run `dart pub get`.
Expand Down

0 comments on commit d34d740

Please sign in to comment.