riverpod icon indicating copy to clipboard operation
riverpod copied to clipboard

There is no way to handle the "done" event on the stream of a StreamProvider

Open miklcct opened this issue 1 month ago • 0 comments

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.

miklcct avatar May 21 '24 10:05 miklcct