这个不起作用(在Cmd-Box的Windows上):
import 'dart:io';
void main() {
print("Hello, World!");
Process.start('cls', [], runInShell: true).then((process) {
stdout.addStream(process.stdout);
stderr.addStream(process.stderr);
});
}
答案 0 :(得分:3)
修改强>
这似乎有答案为什么它不适用于Windows How to make win32 console recognize ANSI/VT100 escape sequences?
<强> ORIGINAL 强>
if(Platform.isWindows) {
// not tested, I don't have Windows
// may not to work because 'cls' is an internal command of the Windows shell
// not an executeable
print(Process.runSync("cls", [], runInShell: true).stdout);
} else {
print(Process.runSync("clear", [], runInShell: true).stdout);
}
或
print("\x1B[2J\x1B[0;0H"); // clear entire screen, move cursor to 0;0
print("xxx") // just to show where the cursor is
// http://en.wikipedia.org/wiki/ANSI_escape_code#CSI_codes
或
for(int i = 0; i < stdout.terminalLines; i++) {
stdout.writeln();
}
光标位置在底部。 您必须在输出后添加换行符才能将其移至顶部。