【发布时间】:2015-11-09 02:44:18
【问题描述】:
所以我是 Dart 和 WebStorm 的新手,我遇到了打印语句的问题。我的代码中有几个打印语句,但是当我运行它时,它们都没有出现。
这是我的代码:
import 'dart:io';
void main() {
int choice = 0;
String line;
String firstName, lastName, contact;
do {
print("Please choose a number: /n");
print("1 - Add a contact /n");
print("2 - Edit a contact /n");
print("3 - Look for a contact /n");
print("0 - Exit application /n");
line = stdin.readLineSync();
choice = int.parse(line);
switch (choice) {
case 1:
{
print("Enter contact's first name: ");
firstName = stdin.readLineSync();
print("Enter contact's last name: ");
lastName = stdin.readLineSync();
print("Enter a contact number: ");
contact = stdin.readByteSync();
print("Is this an office or home contact?");
print("Is this an office or home contact?");
}
case 0:
{
return 0;
}
}
} while (choice > 3 || choice < 0);
}
当我尝试运行控制台时,控制台会显示:
C:\dart-sdk\bin\dart.exe --ignore-unrecognized-flags --checked --enable-vm-service:51901 --trace_service_pause_events "C:\Users\myname\WebstormProjects\untitled\Test .dart"
进程以退出代码 254 结束
【问题讨论】:
-
看起来像 *.com/questions/31122252 的副本
-
但是我没有使用 Dartium。 Dart 的网站说它是可选的。我必须使用 Dartium 才能工作吗?
-
对不起,我错过了你正在导入
dart:io。我不知道你会做错什么,总是为我工作。退出代码 254 表示 Dart 代码因错误而退出。也许您的打印语句根本没有执行。 -
我很确定它应该是
\n而不是/n? -
哦,对不起。但即使没有 \n,它也不会显示在控制台中。