streamRiver function
Implementation
StreamController<_EventWithIndex> streamRiver(
List<Stream<FieldCubitState>> streams) {
late StreamController<_EventWithIndex> controller;
var subscriptions = <StreamSubscription<FieldCubitState>>[];
void startListining() {
for (var i = 0; i < streams.length; i++) {
var stream = streams[i];
subscriptions.add(stream.listen((event) {
controller.add(_EventWithIndex(index: i, state: event));
}));
}
}
void onCancel() {
for (var subscription in subscriptions) {
subscription.cancel();
}
}
controller = StreamController(
onListen: startListining,
onPause: onCancel,
onResume: startListining,
onCancel: onCancel,
);
return controller;
}