gpt4 book ai didi

dart - 控制台应用程序-StringDecoder stdin

转载 作者:行者123 更新时间:2023-12-03 04:31:47 29 4
gpt4 key购买 nike

终端输入显示以下内容或类似内容,但是使用ctl-d终止输入效果不好。还有另一种方法可以退出此“循环”吗?

import "dart:io";

void main() {
stdout.write("Enter Data : ");
new StringDecoder().bind(stdin).listen((String sInput){});
//// Do something with sInput ............
}

最佳答案

使用dart:io时,可以通过运行exit方法来终止dart程序。

void exit(int status)
Exit the Dart VM process immediately with the given status code.

This does not wait for any asynchronous operations to terminate.
Using exit is therefore very likely to lose data.

From the docs

该代码将放入 listen中的事件处理程序中的检查中

关于dart - 控制台应用程序-StringDecoder stdin,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16428292/

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