attach method
Attach to a VM service over its WebSocket URI. Selects the first
isolate exposing ext.flutter.* extensions and listens to the
stderr / stdout / logging event streams. Subsequent calls re-attach.
Implementation
@override
Future<void> attach(Uri vmServiceUri) async {
try {
await _vm.attach(vmServiceUri);
} on TimeoutException {
await _vm.disconnect();
throw RuntimeUnresponsiveError('attach', VmClient.readTimeout);
}
for (final stream in const [
EventStreams.kStderr,
EventStreams.kStdout,
EventStreams.kLogging,
EventStreams.kExtension,
]) {
try {
await _vm.service.streamListen(stream).timeout(VmClient.readTimeout);
} on Object catch (_) {}
}
// Wire disconnect signal: fires once when the WebSocket closes.
unawaited(_vm.service.onDone.then((_) {
if (!_disconnectController.isClosed) {
_disconnectController.add(null);
}
}, onError: (_) {}));
}