Home > Software engineering >  where to get the user input in vs code? using dart
where to get the user input in vs code? using dart

Time:12-23

I am building a dart program to get the user input. when running the program using the run button I get the output in the output window but I cannot type in it. tried using the terminal to run the program and it worked well. so I want to know what is the right way to take the input from the user?

import 'dart:io';

void main() {
  print("enter your name: ");
  var name = stdin.readLineSync();

  print("hello mrs ${name}");
}

CodePudding user response:

The answer regarding using the correct vs-code console use correct but you should also check out the dcli package and it's ask function.

Disclaimer: I'm the author of dcli.

CodePudding user response:

In fact the right way using terminal as you did. It's not a fail. It's just how it works.

  • Related