Visual Studio Code
Installation:
Follow the below steps to set up dart in VS Code:
Step 1: Open Visual Studio Code in your device.
Note: If unavailable then, open “Download Visual Studio Code” and download
the application based on your device’s architecture and configurations.
Step 2: Press “Ctrl + B” and select “Extensions” or directly Press “Ctrl + Shift + X”.
Step 3: In the search bar, type “dart” and open the first extension named “Dart” by “Dart Code” in the list. Press the “Install” button.
Step 4: Once the installation is complete, click “File” and “New File”.
Step 5: Again click “File”, “Save As” and name the file with a “.dart” extension like “gfg.dart”. This file should be saved under a folder, but not as a loose file. So, if needed to create a new folder named “Dart” and save this new file under this folder.
Now, let’s code our first Dart program.
Dart
void main() { print( "Welcome to w3wiki!" ); } |
Step 6: The above code helps us print the string “Welcome to w3wiki!”. Type or copy the above code in the coding area.
Step 7: Save the file by pressing “Ctrl + S” or by selecting “File” and “Save”.
Step 8: Now for running the code, press “Ctrl + Shift + D” and press “Run and Debug” button or open “Run” and select “Start Debugging”.
Step 9: Now a new file named “launch.json” will be created and it opens automatically in VS Code.
Dart
{ // 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 & Flutter" , "request" : "launch" , "type" : "dart" , "program" : "gfg.dart" } ] } |
Step 10: In “launch.json” file, add “program value” inside the curly brackets ({}), like for example {“program” : “gfg.dart”} as shown above and save the file.
Note: If needed add a “,” (comma), to the previous value of "program" in the code of “launch.json” file.
Step 11: Now, press “Run” and then click “Run without Debugging”. The output of the dart file will be displayed in the “Debug Console”.
Dart
Welcome to w3wiki! Exited |
Step 12: Now for running the code in a terminal, press “Terminal” and click “New terminal”.
Step 13: Now in the terminal, type “dart file_name” like “dart gfg.dart” and press “Enter”.
Step 14: The output of the file will get displayed in the terminal.
Dart
PS C:\Users\name\Dart> dart gfg.dart Welcome to w3wiki! |
Output:
Dart – Installation and Setup in Visual Studio Code
Dart is a client-optimized programming language that supports various areas like multi-platform application development, formatting, analyzing, and testing code. It is a programming language that forms the basic foundation of Flutter.
Flutter is an open-source UI – Software development kit that helps develop applications for Android, iOS, Linux, Mac, Windows, Google Fuchsia, and the web in a single code base.
Visual Studio Code is a code editor developed by Microsoft for Windows, Mac, and Linux with features like code debugging, syntax highlighting, code completion, code refactoring, etc.
Contact Us