riverpod
riverpod copied to clipboard
`whenData` of AsyncValue changes `isLoading` and `isRefreshing` to be `false`
Describe the bug
whenData of AsyncValue changes isLoading
and isRefreshing
to be false
.
To Reproduce
The commented out test below will fail. Is this intended behavior?
import 'package:riverpod/riverpod.dart';
import 'package:test/test.dart';
void main() {
test('AsyncValue.when', () {
final previous = AsyncValue<int>.data(1);
final value = AsyncLoading<int>().copyWithPrevious(previous);
expect(value.value, 1);
expect(value, isA<AsyncData<int>>());
expect(value.isLoading, isTrue);
expect(value.isRefreshing, isTrue);
final valueWhen = value.whenData((v) => v);
expect(valueWhen.value, 1);
expect(valueWhen, isA<AsyncData<int>>());
// Failed
/*
expect(valueWhen.isLoading, isTrue);
expect(valueWhen.isRefreshing, isTrue);
*/
});
}
Expected behavior
This test above will be succeeded:
expect(valueWhen.isLoading, isTrue);
expect(valueWhen.isRefreshing, isTrue);