← → or space · progress saves for Continue on the roadmap

Goal

Use Dart’s basic types for numbers, text, and true/false.

Step 1 — int (whole numbers)

void main() {
  int age = 20;
  int count = -5;
  print(age);
  print(count);
}
  • Use int for whole numbers (no decimal).

Step 2 — double (decimal numbers)

void main() {
  double price = 9.99;
  double temperature = -3.5;
  print(price);
  print(temperature);
}
  • Use double for numbers with a decimal part.

Step 3 — String (text)

void main() {
  String name = 'Alice';
  String greeting = "Hello!";
  print(name);
  print(greeting);
}
  • Use single or double quotes for strings.

Step 4 — bool (true/false)

void main() {
  bool isActive = true;
  bool isEmpty = false;
  print(isActive);
  print(isEmpty);
}
  • Use bool for conditions and flags.

Quick reference

Type Example values
int 0, 42, -10
double 3.14, -0.5
String 'hi', "world"
bool true, false

Practice tasks

  • Declare an int for your age and print it.
  • Declare a double for a price and print it.
  • Declare a String for your name and print it.
  • Declare a bool and print it.