I can create Flutter new application using VSCode. Now I want to learn Dart programming language.
How can I create and run a Dart console application Using VS Code?
Answer 1 (Best Answer):
There is an easy way to create and run a Dart console application:
- Open VSCode
- Press cmd + shift + p on Mac or ctrl + shift + p on windows.
- Choose Dart: New project
4. Then you should select Console Application
5. After locating console application everything is ready for you 😊
Well, how to run it? So easy!!!🙂
Just go to terminal and type: “dart main.dart”
or copy the main.dart path then type: “dart (paste main file path)”
or press ctrl + F5
That’s it. I hope you enjoy. 😁
Steps to run in VS Code:
- Open Visual Studio Code.
- Close whatever folder you have open.
- Make sure you have Dart Code Extension installed, or install it if you don’t have it.
- Press Ctrl + Shift + P
- Select Dart: New Project
- Select Console Application
- Type in a name, example: hello_world
- Hit Enter
- Select a folder that already exists.
- Wait until it finishes
- main.dart file will show up.
- Hit Ctrl + F5 to run or Run, Run without debugging.
- In the Debug Console window, you will see the result.
To run a Dart console application:
- Install the Code Runner Extension
- Open the Dart code file in Text Editor, then use shortcut Ctrl+Alt+N, or right-click the Text Editor and then click Run Code in the context menu, the Dart console application will run and the output will be shown in the Output Window.