0Pricing
Dart Academy · Lesson

Anatomy of main() and Hello World

Write and run your very first Dart program.

Anatomy of main() and Hello World is a free Dart Academy lesson on CoddyKit — lesson 3 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Dart Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

Every Program Has a Start

When you run a Dart program, the computer needs to know where to begin. That starting point is a special function called main. 🏁

The main Function

Dart always looks for main first and runs it automatically. Without a main, your program has no place to start.

void main() {
}

What void Means

The word void in front of main means this function gives nothing back. It just does work; it does not return a value.

The Parentheses

The empty parentheses after main are where inputs would go. Main usually needs none, so they stay empty here.

The Curly Braces

The curly braces hold the body of main. Every line you want to run goes between this opening and closing brace.

void main() {
  // your code goes here
}

Saying Hello

The classic first program prints a greeting. Inside main, the print function shows text in your console.

void main() {
  print('Hello, World!');
}

Text Goes in Quotes

The greeting sits inside quote marks, which makes it a String. Quotes tell Dart this is plain text, not code to run.

End With a Semicolon

Each instruction ends with a semicolon. It is like a period in a sentence, marking where one statement stops.

Running Your Program

Save your file as hello.dart, then use the dart run command in the terminal to execute it and see the output.

dart run hello.dart

Seeing the Output

After running, your terminal proudly shows Hello, World! That printed line is your output: proof your code worked. 🎉

Why This Matters

Tiny as it looks, this program teaches the real shape of Dart: a main function with statements inside braces. Everything builds from here.

Quick Check

Let's check where a Dart program begins.

Recap

You met main: void plus parentheses plus braces, with print inside ending in a semicolon. You ran your first Dart program. 🚀

Frequently asked questions

Is the “Anatomy of main() and Hello World” lesson free?

Yes — the full text of “Anatomy of main() and Hello World” is free to read here on the web, and the Dart Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Dart Academy course, upgrade to CoddyKit PRO.

What will I learn in “Anatomy of main() and Hello World”?

Write and run your very first Dart program. You practise Dart Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start Dart Academy?

No prior experience is required. Dart Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 3 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Anatomy of main() and Hello World” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this Dart Academy lesson?

Yes. Every Dart Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. What Dart Is and Why It Exists
  2. Install the SDK and Check Your Version
  3. Anatomy of main() and Hello World
  4. Printing, Comments, and Statements
← Back to Dart Academy