Skip to content

Commit

Permalink
Fix family.overrideWith cast error and include family arguments in th…
Browse files Browse the repository at this point in the history
…e ref (#2852)

fixes #2832
fixes #2851
  • Loading branch information
rrousselGit authored Aug 28, 2023
1 parent 4461140 commit 41f020d
Show file tree
Hide file tree
Showing 45 changed files with 2,647 additions and 341 deletions.
5 changes: 2 additions & 3 deletions examples/counter/lib/main.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

122 changes: 108 additions & 14 deletions examples/pub/lib/detail.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

66 changes: 60 additions & 6 deletions examples/pub/lib/search.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions packages/riverpod/lib/src/async_notifier/auto_dispose.dart
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,17 @@ class AutoDisposeAsyncNotifierProviderImpl<

@override
AutoDisposeAsyncNotifierProviderElement<NotifierT, T> createElement() {
return AutoDisposeAsyncNotifierProviderElement._(this);
return AutoDisposeAsyncNotifierProviderElement(this);
}

@override
@mustBeOverridden
FutureOr<T> runNotifierBuild(AsyncNotifierBase<T> notifier) {
return (notifier as AutoDisposeAsyncNotifier<T>).build();
}

/// {@macro riverpod.overridewith}
@mustBeOverridden
Override overrideWith(NotifierT Function() create) {
return ProviderOverride(
origin: this,
Expand All @@ -119,5 +121,6 @@ class AutoDisposeAsyncNotifierProviderElement<
with AutoDisposeProviderElementMixin<AsyncValue<T>>
implements AutoDisposeAsyncNotifierProviderRef<T> {
/// The [ProviderElementBase] for [AsyncNotifierProvider]
AutoDisposeAsyncNotifierProviderElement._(super._provider) : super._();
@internal
AutoDisposeAsyncNotifierProviderElement(super._provider) : super();
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class AutoDisposeFamilyAsyncNotifierProviderImpl<

@override
AutoDisposeAsyncNotifierProviderElement<NotifierT, T> createElement() {
return AutoDisposeAsyncNotifierProviderElement._(this);
return AutoDisposeAsyncNotifierProviderElement(this);
}

@override
Expand Down
14 changes: 10 additions & 4 deletions packages/riverpod/lib/src/async_notifier/base.dart
Original file line number Diff line number Diff line change
Expand Up @@ -131,15 +131,17 @@ class AsyncNotifierProviderImpl<NotifierT extends AsyncNotifierBase<T>, T>

@override
AsyncNotifierProviderElement<NotifierT, T> createElement() {
return AsyncNotifierProviderElement._(this);
return AsyncNotifierProviderElement(this);
}

@override
@mustBeOverridden
FutureOr<T> runNotifierBuild(AsyncNotifierBase<T> notifier) {
return (notifier as AsyncNotifier<T>).build();
}

/// {@macro riverpod.overridewith}
@mustBeOverridden
Override overrideWith(NotifierT Function() create) {
return ProviderOverride(
origin: this,
Expand Down Expand Up @@ -472,7 +474,9 @@ abstract class AsyncNotifierProviderElementBase<
NotifierT extends AsyncNotifierBase<T>,
T> extends ProviderElementBase<AsyncValue<T>>
with FutureHandlerProviderElementMixin<T> {
AsyncNotifierProviderElementBase._(super._provider);
/// The element of [AsyncNotifierProvider].
@internal
AsyncNotifierProviderElementBase(super._provider);

final _notifierNotifier = ProxyElementValueNotifier<NotifierT>();

Expand Down Expand Up @@ -501,9 +505,11 @@ abstract class AsyncNotifierProviderElementBase<
class AsyncNotifierProviderElement<NotifierT extends AsyncNotifierBase<T>, T>
extends AsyncNotifierProviderElementBase<NotifierT, T>
implements AsyncNotifierProviderRef<T> {
AsyncNotifierProviderElement._(
/// The element of [AsyncNotifierProvider].
@internal
AsyncNotifierProviderElement(
AsyncNotifierProviderBase<NotifierT, T> super._provider,
) : super._();
);

@override
void create({required bool didChangeDependency}) {
Expand Down
2 changes: 1 addition & 1 deletion packages/riverpod/lib/src/async_notifier/family.dart
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class FamilyAsyncNotifierProviderImpl<NotifierT extends AsyncNotifierBase<T>, T,

@override
AsyncNotifierProviderElement<NotifierT, T> createElement() {
return AsyncNotifierProviderElement._(this);
return AsyncNotifierProviderElement(this);
}

@override
Expand Down
Loading

0 comments on commit 41f020d

Please sign in to comment.