piechowiakmichal · GitHub

Hello, I have such a simple code in Dart:

import 'dart:io';
void main() {
  print('How old are you?');
  String age = stdin.readLineSync();
  print('You have $age age');
}

When I run it using cmd, it fires up normally, ie it prints the first print, gets the keyboard input, and prints the second print. When I run it with VS Code, the script prints the first print and then reads the keyboard data in a loop, it doesn't go to the second print.

I fixed it by configuring launch.json:

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Dart",
            "program": "${file}",
            "request": "launch",
            "type": "dart",
            "console": "terminal"
        }
    ]
}

I added "console": "terminal".

Now the program starts, but as soon as the program finishes, the terminal crashes and gets an error:

The terminal process "C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe" terminated with exit code: 1.

The same thing happens with cmd:

The terminal process "C:\WINDOWS\System32\cmd.exe" terminated with exit code: 1.

What can I do to make the program run after clicking F5, execute correctly and not to turn off the terminal immediately after executing the program?

In the attachment there is Dart: Capture Logs.
Dart-Code-Log-2020-07-06 11-56-43.txt

Read the original on github.com ↗