dartvisual-studio-codeinputuser-inputstdin

undetectable Dart-Input in Visual Code Studio


I made a script in in Visual Studio Code using Dart that grabs the user's input. The problem is, that if I enter something in the input line in vscode, which is located below the debug console and press enter, nothing happens.

import 'dart:io'

void main() {
  print("testing space\n-------------------");

  String? s = stdin.readLineSync();

  print(s);
}

I did more research (I didn't). I haven't found anything to this problem yet except for using the terminal


Solution

  • The debug console does not accept user input. Try running your program in the terminal (the tab on the right):

    $ dart main.dart
    testing space
    -------------------
    hi
    hi