Dart – Hello World

In this tutorial, we will write a very basic Dart program. This sample program, prints Hello World to the console.

Open a text editor and paste the following code.

void main(){
	print('Hello World');

Save the file as hello.dart or some_file_name_you_like.dart. Let us continue with hello.dart.

Open Command Prompt and go to the folder, in which the hello.dart file is saved.

Execute the following command to run hello.dart present in the current working directory.

Dart Hello World

The program is run successfully and Hello World string is printed to console.

Now, we shall look into the program and analyze the code.

Following is our dart program.

void main(){
	print('Hello World');

Every Dart application has a main function main().

void represents that the function returns nothing.

Empty parenthesis after main () represents that currently our main function does not take any arguments.

The body of main() function is enclosed in curly braces  { } .

print() is a high level Dart function that prints to console.



In this Dart Tutorial, we learned how to write a simple hello world program in Dart programming language and run it using dart command.