Dart Get Started
Getting started with Dart means writing a program file and running it. The program file in this course is main.dart.
A one statement file
This file holds one statement inside main. The statement shows one line.
void main() {
print('Ready');
}Statements in order
Step one appears above Step two in the output. The order on screen matches the order in the file.
void main() {
print('Step one');
print('Step two');
}A short first run
This file holds two statements. Each statement shows its own line.
void main() {
print('My program');
print('It works');
}Example
void main() {
print('Program starts');
print('Program ends');
}Key points
- The program file in this course is main.dart.
- Use dart main.dart to run the file.
- main is the part of the program that runs first.
- A statement is one complete instruction in a program.
- Statements run from top to bottom.
- A print statement ends with a semicolon.
In this example, the first statement shows Program starts. The second statement shows Program ends below the first line.
Try it Yourself
Edit the code, then press Run.
Running is simulated ยท DartPad
Exercise
Which command runs the file main.dart?