What is Dart?
1. Dart is Object oriented and string typed, developed by google in 2011.
2. It is a mixture of Java & JavaScript. Dart is an open-source programming language which is widely used to develop the mobile application, modern web-applications, desktop application, and the Internet of Things (IoT) using by Flutter framework.
3. It is a compiled language and supports two types of compilation techniques.
//main function will be like this
void main() {
print('Hello world');
}
//Hello world
Using Variables in Dart
Using keyword “var” we can create a variable.
void main() {
String name = "Nandan";
var email = "gnnandan7@gmail.com";
print(name);
print(email);
}
//Nandan
//gnnandan7@gmail.com
Display Formatted Value
Using $VariableName
we can print the formatted output in dart
void main() {
String name = "Nandan";
var email = "gnnandan7@gmail.com";
// print(name);
// print(email);
print("My name is $name and Email is $email");
}
//My name is Nandan and Email is gnnandan7@gmail.com
Project – 1 Basic Calculator
In this page we are doing simple calculator app using dart
void main() {
int num1 = 100;
int num2 = 200;
int sum = num1 + num2;
int diff = num2 - num1;
int product = num1 * num2;
double div = num1 / num2;
// displaying the output
print("The sum is $sum");
print("The diff is $diff");
print("The mul is $product");
print("The div is $div");
}
//The sum is 300
// The diff is 100
// The mul is 20000
// The div is 0.5