Hello World in Dart Programming

A Hello World program is the first program that you learn whenever you are learning a new programming language. It might be a simple program but it is a great entry point as you get to know how a program works in Dart, how to run a dart file. It provides a way to test the systems and environment that you are using.

An important prerequisite before running a Hello World in Dart is to have the Dart SDK installed on your local machine. You can install the Dart SDK from this link.

Writing Hello World Program

The first thing that you need to do is open the terminal or cmd (if you are on Windows) and then run the following command −

touch hello_world.dart

The above command will work on macOS and Linux operating systems. For windows, you can use any text editor of your choice and then save the file with the .dart extension.

The program will look something like this −

Example

Live Demo

void main(){
print("Hello World");
}

Output

Hello World

It looks very simple, in fact, it is. Though we need to understand some of the keywords that we used in the above program to understand it better.

• main - the entry point of our program.

• void - the keyword that tells the compiler that we are not returning anything from the function.

• print - the print function is used to print (output) whatever we put inside the parentheses.