是否可以在 Dart 中运行外部命令?我需要运行外部命令plutil,但是我谷歌搜索的所有内容都会给我从命令行运行 Dart 代码的结果,所以我一直无法找到解决方案。谢谢!
示例Run external command in dart:
import 'dart:io';
void main(List<String> args) async {
var executable = 'ls';
if (Platform.isWindows) {
executable = 'dir';
}
final arguments = <String>[];
print('List Files and Directories');
print('============');
final process = await Process.start(executable, arguments, runInShell: true);
await stdout.addStream(process.stdout);
await stderr.addStream(process.stderr);
final exitCode = await process.exitCode;
print('============');
print('Exit code: $exitCode');
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1269 次 |
| 最近记录: |