Dart First ProgramAs we have discussed earlier, Dart is easy to learn if you know any of Java, C++, JavaScript, etc. The simplest "Hello World" program gives the idea of the basic syntax of the programming language. It is the way of testing the system and working environment. In this tutorial, we will give the basic idea of Dart's syntax. There are several ways to run the first program, which is given below:
Before running the first program, it must ensure that we have installed the Dart SDK properly. We have discussed the complete installation guide in our previous tutorial. Let's run our first program. Using Command LineStep - 1: Type dart on the terminal if it is showing dart runtime then Dart is successfully installed. Step - 2: Open a text editor and create a file called "helloword.dart". The file extension should be .dart that specifies; it is a Dart program file.
Step - 3: Open the command line; compile the program run the Dart program by typing dart helloworld.dart. It will show Hello World on the screen. Running on BrowserDart provides an online editor which is known as DartPad available at https://dartpad.dartlang.org/. On the left side, we can write the code and the output displays on the right side of the screen. We can add HTML and CSS with the Dart Code. Dart also provides some sample programs to learn. Let's have a look at the following image. Using IDEThere are various IDEs that support Dart, such as Visual Studio Code, WebStorm, IntelliJ, etc. For the visual studio code, download the dart extension and run the code. We recommend running the Dart code using the command line or IDE.
Next TopicDart Basic Syntax
|