Dart : Your First Hello, World! Program

Before we begin, ensure that you have Dart installed on your system

1. Create a Dart Script File:

Start by creating a new file for your Dart program

Save the file with a ".dart" extension, for example,"hello_world.dart".

 

2. Write the Dart Code:

Open the "hello_world.dart" file and add the following Dart code:

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

In Dart, the main() function is the entry point for your program.

The print() function is used to display output, and in this case, it will print "Hello, World!" to the console.

 

3. Open a Terminal or Command Prompt:

Open Command Prompt or Terminal in your Windows system.

Use the "cd" command to navigate to the directory where your "hello_world.dart" file is located.

 

4. Execute the Dart Program:

Run your Dart program by using the dart command followed by the name of your Dart script:

"dart hello_world.dart".

After executing this command, you should see the following output in your terminal:

 

You've just written and executed your first Dart program.

This "Hello, World!" program is a small but significant step in your journey to becoming proficient in Dart.