call method
Implementation
Future<ProcessDetails> call(
String executable,
List<String> arguments, {
String? workingDirectory,
Map<String, String>? environment,
bool includeParentEnvironment = true,
bool runInShell = false,
io.ProcessStartMode mode = io.ProcessStartMode.normal,
}) async {
final process = await io.Process.start(
executable,
arguments,
workingDirectory: workingDirectory,
environment: environment,
includeParentEnvironment: includeParentEnvironment,
runInShell: runInShell,
mode: mode,
);
final stdoutController = StreamController<List<int>>.broadcast();
final stderrController = StreamController<List<int>>.broadcast();
try {
process.stdout.listen(stdoutController.add);
} catch (_) {}
try {
process.stderr.listen(stderrController.add);
} catch (_) {}
Stream<String> stdout() async* {
try {
yield* stdoutController.stream.transform(utf8.decoder);
} catch (_) {
// ignore
}
}
Stream<String> stderr() async* {
try {
yield* stderrController.stream.transform(utf8.decoder);
} catch (_) {
// ignore
}
}
return ProcessDetails(
stdout: stdout().join(),
stderr: stderr().join(),
exitCode: process.exitCode,
);
}