connected property
A broadcast stream of connection state changes. New subscribers receive the current state as the first event (replay-1).
Implementation
Stream<bool> get connected {
late StreamController<bool> wrapper;
StreamSubscription<bool>? sub;
wrapper = StreamController<bool>(
onListen: () {
wrapper.add(_isConnected);
sub = _connected.stream.listen(wrapper.add);
},
onCancel: () async {
await sub?.cancel();
},
);
return wrapper.stream;
}