You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
provider.asData?.value is returning previous value even if isLoading is true.
To Reproduce
// declare some basic provider (reproduced with Family provider but I guess it should occur without Family as well)@riverpodFuture<int?> someData(SomeDataRef ref, {requiredint something}) async {
awaitFuture.delayed(Duration(seconds:10));
return something;
}
...
// in build:final data = ref.watch(someDataProvider(0));
print("${data.isLoading} ${data.asData?.isLoading} ${data.asData?.value != null}");
...
// invalidate provider somewhere else
ref.invalidate(someDataProvider(0));
Once value is there, after invalidate isLoading will be = true, but data.asData?.value will still be holding a value (it will not map it to null as expected). So before new value is loaded you get true true true as output (which in theory should never happen).
/// If you do not want to return previous value during loading/error states,
/// consider using [asData] :
///
/// ```dart
/// ref.watch(provider).asData()?.valueOrNull;
/// ```
/// Upcast [AsyncValue] into an [AsyncData], or return null if the [AsyncValue]
/// is in loading/error state.
If that's expected behavior, then it is completely different from what docs describe it to be.
Describe the bug
provider.asData?.value is returning previous value even if isLoading is true.
To Reproduce
Once value is there, after invalidate
isLoading
will be =true
, butdata.asData?.value
will still be holding a value (it will not map it to null as expected). So before new value is loaded you gettrue true true
as output (which in theory should never happen).Even with .map you get:
loading
is never fired in this case.Expected behavior
When isLoading = true, asData?.value should be null (which is how docs describe it as well).
The text was updated successfully, but these errors were encountered: