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:

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)

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:
3

Run the program

Execute the program from your terminal:
4

See the output

You should see the output:
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:
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.