Dart Crash Course for Flutter
What is Dart? it’s coding language to make multi-platform apps. (With flutter framework) it’s a Static typed language. that means the type of a variable is fixed once it’s declared. var name = "piyush"; // Decleared as String name = 12; ...

What is Dart?
it’s coding language to make multi-platform apps. (With flutter framework)
it’s a Static typed language. that means the type of a variable is fixed once it’s declared.

var name = "piyush"; // Decleared as String
name = 12; // ❌ NOT correct
Dart Basic :
Hello world:
→ In dart all the code execute from the void main function so any code written under this will be executed.
void main() {
print("hello dart");
}
Variable:
→Variable is the name of the in the memory space that acct as the container where the value is stored.

→ Type of Datatype:
Basic Datatype like :
Int → number
String → word/alphabet
Boolean →true/false
void main() {
const ayush= "piyush"; // string
const age=19; // int-> number
const isAdult=true; // boolean
print("my name is $ayush who is $age old");
}
→ There are many type of varriable in dart:
- Var: allows changing the value, but the type is fixed after the first assignment.
void main() {
var ayush="piyush";
ayush="ritam";
print(ayush);
}
- Final: when we can value of the variable don't change after assigning the value we need to use “Final”. It’s used when we want that data should not be changed and also we don’t know what will be inside that variable like data from API.
Let’s see this in action:
- Code:
void main() {
final ayush="piyush";
ayush="ritam";
print(ayush);
}
- Output:

So as we see this will give error. So let’s see the correct example.
- Code:
void main() {
final ayush="piyush";
print(ayush);
}
- Output:
piyush
- Const: when we want the variable don't change after assigning the value we need to use “Const”. It’s used we know what will be inside that variable.
- Code:
void main() {
const ayush="piyush";
print(ayush);
}
- output:
piyush
- Mathematical Area:
void main() {
const ayush= 25;
print(ayush+10);
print(ayush-10);
print(ayush*10);
print(ayush/10);
print(ayush%10); // give remainder
}
- Output:
35
15
250
2.5
5
String Interpolation :
Adding string not by string con-catenation.
void main() {
const ayush= "piyush";
print("my name is "+ ayush); // string con-catination
print("my name is $ayush"); // string interpolation
}
Type Annotation :