User Input

If you are using VS code, you need to follow some additional steps:

1) Open a folder with VS code.
2) Create a new file "test.dart".
3) Click Run > Open configurations.



4) A file called "launch.json" will be opened.



5) Add this new configurations.



6) Open "Run" from left side then change the configurations to "Dart with UserInput".



The readLineSync() method of stdin allows to capture a String from the console.

7) Rewrite these lines to try it and run the program with the left side button .

import 'dart:io';

 

void main() {

  print("Type something");

  var input = stdin.readLineSync();

  print("you typed $input");

}





8) Type something in the terminal and click "Enter".