buffer events to avoid lifecycle issues

This commit is contained in:
Fabian Freund
2025-10-26 03:40:06 +01:00
parent 2bd38c5366
commit ccc22f57f0
@@ -58,10 +58,25 @@ class EngineBoundIntentStream extends _$EngineBoundIntentStream {
final sharingItentStream = ref.watch(sharingIntentStreamProvider); final sharingItentStream = ref.watch(sharingIntentStreamProvider);
final appWidgetLaunchStream = ref.watch(appWidgetLaunchStreamProvider); final appWidgetLaunchStream = ref.watch(appWidgetLaunchStreamProvider);
return MergeStream([ // Create a broadcast stream controller to buffer events
sharingItentStream.transform(_contentParserTransformer), final controller = StreamController<SharedContent>.broadcast();
appWidgetLaunchStream.transform(_contentParserTransformer),
]); final subscription =
MergeStream([
sharingItentStream.transform(_contentParserTransformer),
appWidgetLaunchStream.transform(_contentParserTransformer),
]).listen(
controller.add,
onError: controller.addError,
onDone: controller.close,
);
ref.onDispose(() async {
await subscription.cancel();
await controller.close();
});
return controller.stream;
} }
@override @override