Dart 2 programming language Writing your first program (Introduction)

Dart program was initially developed by Google. It is an open source programming language. It is an object-oriented, class defined, single inheritance language. This is our first tutorial on Dart. Dart is a relatively new programming language and the cool thing about this language is that you can develop almost any type of application using Dart. You can develop Android or iOS applications (using Flutter), create a web app and create command line or server side app. Dart is easy to learn. If you are familiar with any object-oriented language, then it will not take much time to grab. Follow our tutorials and keep practicing.

How to run a Dart program :

1. Using command line :

You can start dart development on any OS or even on a browser. First of all, to run a dart program, you need to download the dart sdk from here. I am not going to cover the full installation tutorial because it is different on different operating system. Now :

  1. Type dart on a terminal. If it is showing the dart runtime, the installation is successful. Make sure to add it to the PATH variable for windows.
  2. To run a dart program, we need to create one .dart file and we can run it using dart filename.dart.

2. Running on a browser :

Dart provides one online editor (known as dartpad) https://dartpad.dartlang.org/ to test dart language. It runs the code and shows it on the console on the right side. You can even add html and css code to this dartpad. Dartpad also contains a few sample program to learn. It looks like as below :

3. Using one IDE :

Most popular IDE supports dart. For example, you can run dart on IntelliJ, Eclipse, WebStorm or even on Visual Studio Code. We recommend using a command line or visual studio code for learning simple dart programs. For visual studio code, you can download dart extension.

How a hello world program looks like :

 print("Hello World !!");

Same as most of the other languages, Dart also runs the main() program first. You can copy the above code in a .dart file and try to run it using a command line.