in lib/src/stream_group.dart [140:157]
Future<void>? add(Stream<T> stream) {
if (_closed) {
throw StateError("Can't add a Stream to a closed StreamGroup.");
}
if (_state == _StreamGroupState.dormant) {
_subscriptions.putIfAbsent(stream, () => null);
} else if (_state == _StreamGroupState.canceled) {
// Listen to the stream and cancel it immediately so that no one else can
// listen, for consistency. If the stream has an onCancel listener this
// will also fire that, which may help it clean up resources.
return stream.listen(null).cancel();
} else {
_subscriptions.putIfAbsent(stream, () => _listenToStream(stream));
}
return null;
}