riverpod
riverpod copied to clipboard
There is no way to handle the "done" event on the stream of a StreamProvider
Describe the bug There is no way to handle the "done" event on the stream of a StreamProvider. In particular, a StreamProvider constructed using an empty stream will stuck forever in the "loading" state.
To Reproduce
final provider = StreamProvider((ref) => const Stream<int>.empty());
class MyWidget extends ConsumerWidget {
@override
Widget build(BuildContext context, WidgetRef ref) =>
ref.watch(provider).when(
data: (x) => Text(x.toString()),
error: (e, st) => const Text('Error'),
loading: () => const Text('Loading'),
);
}
The widget is stuck in loading.
Expected behavior
There should be a way to find out if the AsyncValue
is done.