runScript method
Implementation
@override
Future<CommandResult> runScript(
String script, {
required bool showOutput,
}) async {
final port = ReceivePort();
final isolate = await Isolate.spawn(
_runScript,
port.sendPort,
);
final completer = Completer<CommandResult>();
await for (final event in port) {
if (event is SendPort) {
event.send({
'script': script,
'showOutput': showOutput,
});
} else if (event is Map) {
final result = CommandResult.fromJson(event);
completer.complete(result);
break;
}
}
await completer.future;
isolate.kill();
return completer.future;
}