vmServiceConnectUri function Null safety
Connect to the given uri and return a new VmService instance.
Implementation
Future<VmService> vmServiceConnectUri(String wsUri, {Log? log}) async {
final WebSocket socket = await WebSocket.connect(wsUri);
final StreamController<dynamic> controller = StreamController();
final Completer streamClosedCompleter = Completer();
socket.listen(
(data) => controller.add(data),
onDone: () => streamClosedCompleter.complete(),
);
return VmService(
controller.stream,
(String message) => socket.add(message),
log: log,
disposeHandler: () => socket.close(),
streamClosed: streamClosedCompleter.future,
);
}