This section introduces the use of variables and how to print output in Dart.
void main() {
print("Hello world");
}Output:
Hello world
void main() {
// Basic types
int age = 21;
double height = 5.9;
String name = "Sharada";
bool isStudent = true;
// Printing
print("Name: $name");
print("Age: $age");
print("Height: $height");
print("Student: $isStudent");
}Explanation:
int,double,String, andboolare basic data types in Dart.- Dart uses string interpolation (
$variableName) to insert variable values into strings. print()is used to display output.
Output:
Name: Sharada
Age: 21
Height: 5.9
Student: true