mydomain
No ADS
No ADS

Run your first Dart example in Visual Studio Code

  1. Article objective
  2. Create Project on VS Code
  3. Add dart file to the project

1. Article objective

In this article I'm going to show you how to create a simple Dart example on Visual Studio Code and run it successfully. First and foremost, make sure that you have already installed the Dart Code Extension in Visual Studio Code, otherwise you can refer to the following article:
Note that apart from Visual Studio Code, there are a lot of IDE(s) in support of Dart programming, such as Android Studio, IntelliJ IDEA,etc. Thus, the following articles may be useful for you:

2. Create Project on VS Code

No ADS
On Visual Studio Code press the key combination:
  • Cmd + Shift + P (Mac OS)
  • Ctrl + Shift + P (Windows)
Select "Dart: New Project".
Next, select "Console Application":
Next, select the folder to store the project to be created, for example:
  • C:/DART
Enter the project name:
  • myfirstproject
A project has just been created with a sample dart file:
myfirstproject.dart
import 'package:myfirstproject/myfirstproject.dart' as myfirstproject;

void main(List<String> arguments) {
  print('Hello world: ${myfirstproject.calculate()}!');
}
To run the dart file, right-click it and select:
  • Run Without Debugging
And you will see the result on the DEBUG CONSOLE window:

3. Add dart file to the project

To create a new dart file, right click on the project's "bin" folder and select:
  • New File
test.dart
void main()  {
  print("Hello World!");
}
No ADS
No ADS