Dart 为什么我的主机没有';你不能用这个密码回答吗?飞奔

Dart 为什么我的主机没有';你不能用这个密码回答吗?飞奔,dart,input,console,Dart,Input,Console,控制台不响应此代码。在这里,我尝试使用stdout.write()而不是print()。 “为方便起见,我使用Microsoft VS代码。” import 'dart:io'; void main() { stdout.write('Enter your name:'); String name = stdin.readLineSync(); //Read name stdout.write('Enter your age:'); int age

控制台不响应此代码。在这里,我尝试使用stdout.write()而不是print()。 “为方便起见,我使用Microsoft VS代码。”

import 'dart:io';

void main() {

  

  stdout.write('Enter your name:');
  String name = stdin.readLineSync();   //Read name

  stdout.write('Enter your age:');      
  int age = int.parse(stdin.readLineSync());   //Read age as int

  stdout.write('You are $age and your name is $name');

}

你说“不回应”是什么意思?它不输出任何东西吗?或者,在您单击“输入”后写入输入后,它是否不接受输入?
stdout。写入
不是您想要的。您需要使用
打印(myTextStatement)
。这应该打印一些东西。您是否收到任何错误?@julemand101在VS代码中,我看到输出为“连接到ws://127.0.0.1:65323/BV2ukCkUinE=/ws处的VM服务”--输出-------然后退出。在这段代码中,我只看到“连接到虚拟机服务,网址为ws://127.0.0.1:65323/BV2ukCkUinE=/ws”@siddhartapandey如果您将其更改为简单的
print('Hello World')
?@julemand101,则在使用“print”而不是stdout.write时,只会给出第一条语句“输入您的姓名:”。我无法在输出控制台中输入任何值。此外,我在dartpad中尝试了这段代码,它给出的错误是不支持的“dart:io”。我认为还有另一个库供用户输入。这可能是我不知道的最近更新的。