gpt4 book ai didi

dart - 有没有办法同步运行 Dart 的 Future?

转载 作者:行者123 更新时间:2023-12-04 11:09:26 24 4
gpt4 key购买 nike

如何立即获得 Future 的结果?例如:

void main() {
Process.run('some_shell_command', []).then((ProcessResult result) {
print(result.stdout); // I have the output here...
});
// ... but want it here.
}

最佳答案

the support of await 处于实验状态,可以像这样使用:

void main() async {
ProcessResult result = await Process.run('some_shell_command', []);
print(result.stdout); // I have the output here...
}

关于dart - 有没有办法同步运行 Dart 的 Future?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14820702/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com