I receive data from a BLE unit and have a broadcast stream exposed by a singleton locator (Get_It) to my application.
From the data, I want to build several small display widgets that need to display different information based on the same data stream, however, only the last of my 3 widgets listens to, and receives the stream information.
I was under the impression that, a broadcast stream makes itself available to more than one listener, however, this is clearly not the case, unless I have it wrong.
For reference, here's the exposure via my sessionManager
:
Stream<dynamic> get pairAndListen => AppSDK.unit
.pair()
.asBroadcastStream()
AppSDK.unit
is a call to a Flutter plugin, that exposes the BLE's characteristics by the manufacturer's supplied SDK for both Android and iOS (reactive_ble and the likes will not work here as it's IP locked behind their SDK's).
As per my understanding setting it up as a broadcast stream should allow multiple listeners receive the feedback?
An example of my widgets:
widget_1.dart
Widget1(stream: sessionManager.pairAndListen)
widget_2.dart
Widget2(stream: sessionManager.pairAndListen)
What I'm actually doing, the widgets are on a dashboard, wrapped in a Column(), each receiving the stream from the sessionManager, however, only the last one of the 3 widgets work; the other two is completely ignored.
If I wrap my Column() with a single StreamBuilder
and pass the result from the callback to each of the widgets, it obviously works as there's only one listener, however, I want each of my widgets to manage the response differently within themselves.
Am I missing something in regards to the use of asBroadcastStream?