Skip to main content

Introduction

Every programming journey begins with a simple “Hello World” program. In Dart, this is incredibly straightforward and demonstrates the basic structure of a Dart application.

The Hello World Program

Here’s the complete Hello World program in Dart:
void main() {
  print('Hola!!!');
}

Understanding the Code

Let’s break down each part of this simple program:
The main() function is the entry point of every Dart application. When you run a Dart program, execution starts here.
  • void indicates that this function doesn’t return a value
  • main is the required name for the entry point function
  • () indicates this function takes no parameters (for now)
The print() function displays output to the console.
  • It accepts a value (in this case, a String) as a parameter
  • The text is enclosed in single quotes '...' (you can also use double quotes "...")
  • Each statement in Dart ends with a semicolon ;

Running Your First Program

1

Create a file

Create a new file named hello_world.dart in your project directory.
2

Write the code

Copy the Hello World code into your file:
void main() {
  print('Hola!!!');
}
3

Run the program

Execute the program from your terminal:
dart hello_world.dart
4

See the output

You should see the output:
Hola!!!
You can change the message inside print() to display any text you want. Try experimenting with different messages!

Try It Yourself

Modify the program to display your own message:
void main() {
  print('Welcome to Dart programming!');
  print('My name is [Your Name]');
  print('I am learning Dart!');
}
Each print() statement outputs text on a new line. You can call print() multiple times to display multiple lines of output.

Next Steps

Now that you’ve created your first Dart program, you’re ready to learn about variables and how to store data in your programs.

Build docs developers (and LLMs) love