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 appWidgetLaunchStream = ref.watch(appWidgetLaunchStreamProvider);
return MergeStream([
sharingItentStream.transform(_contentParserTransformer),
appWidgetLaunchStream.transform(_contentParserTransformer),
]);
// Create a broadcast stream controller to buffer events
final controller = StreamController<SharedContent>.broadcast();
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