In Dart language we also faces with variables/identifiers.
Variables are those names which stores same value into memory.
Identifiers in Dart actually a name given to program elements which can be functions, variables, array etc. The first character of an identifier in dart cannot begin with a digit, it can include letters,underscores and digits.
This identifiers also found in python.
Fun fact: in dart language, we can create static and dynamic variables also.
Static Variables Declaration –
We generally define variables by using keyword – ‘var’. It’s automatically detects variables datatype during runtime of program.
Let’s see some codes…
Code 1:
void main(){ var a=34; print(‘$a’); } |
code 2:
void main(){ var a=’microcodes’; print(‘$a’); } |
code 3:
void main(){ // float variables var b=67.9; print(“$b”); } |

We can create variables by using its data type declaration…
Code 4:
void main() { int a = 9; print(‘a is $a’); String b = ‘india’; print(‘b is ‘ + b); double per = 3.4; print(‘percentage is $per’); // prints variables datatype… print(‘Integer a type ‘); print(a.runtimeType); print(‘String b type ‘); print(b.runtimeType); print(‘Double per type ‘); print(per.runtimeType); } |

Discuss: int a => means we declares variable ‘a’ is integer type, so it can holds only integer values not strings/doubles.
** In dart, we can’t use float datatype instead of ‘double’.
** Integers and double data types counted into ‘numbers’ data type in dart language. We can also say, Numbers (integers and double).
Boolean data-types: Boolean variables represented using data-type ‘bool’.
Code 5:
void main(){ // boolean bool flag=true; print(‘$flag’); flag=false; print(‘$flag’); } |

Dynamic Variables Declaration
In dart, we can declare dynamic variables as well, but how? Let’s see…
late keyword :
late modifier means “enforce this variable’s constraints at runtime instead of at compile time”. It’s almost like the word “late” describes when it enforces the variable’s guarantees.
In Dart, we use the late keyword to declare variables that will be initialized later. These are called non-nullable variables as they are initialized after the declaration.
Code 6:
void main(){ late var a; a=10; print(‘variable a is: $a’); print(‘variable type: ‘); print(a.runtimeType); a=’dart’; print(‘variable a is: $a’); print(‘variable now: ‘); print(a.runtimeType); } |

Symbols – In Dart, Symbols are basically an object representation of either an identifier or operator. It can be used for reflecting the metadata on a type, such as a library or class. They are generally used for creating APIs and establish a relationship between a string that is understandable to humans and a string that can be used by computers.
Symbols can be used to get various information about a type (library, class, etc) such as a list of instance methods, constructors, etc.
Way 1: to declare and print symbols
print(#mysqlAPI); print(#NodeJsAPI); |
Way 2: a symbol can be created explicitly using the Class constructor.
// symbols way – 2 Symbol MySqlAPI = Symbol(‘MySqlAPI’); print(MySqlAPI); Symbol MongoDBinSert = Symbol(‘MongoDBinSert’); print(MongoDBinSert); |
late for static variables – generally late keyword uses for those variables, which will initialized after in the program. Generally dart does not offers you to declare NULL valued variables, but using ‘late’ keyword we can achieve this. Its helps to declare and initialize values after concepts by programmers.
Code 7:
void main(){ // late variables late String a; a=’microcodes’; print(‘a variable : $a’); late int b; b=90; print(‘b variable : $b’); late double c; c=45.6; print(‘c variable : $c’); } |

Final variables
These variables are those whose values can’t be change after one time declaration.
Code 8:
void main(){ final a=90; a=80; print(‘$a’); } |

Let’s see another example…
Code 9:
void main(){ // phase 1 final int a=90; print(a); a=100; print(a); // phase 2 final String b=”das”; b=”saha”; print(b); } |

Code 10:
void main(){ // phase 1 final var a=90; print(a); a=100; print(a); // phase 2 final var b=”das”; b=”saha”; print(b); } |

Const variables
In simple words, we can say keyword ‘const’ works same as keyword ‘final’. Use const for variables that you want to be compile-time constants. If the const variable is at the class level, mark it static const. Where you declare the variable, set the value to a compile-time constant such as a number or string literal, a const variable, or the result of an arithmetic operation on constant numbers:
Note: Although a final object cannot be modified, its fields can be changed. In comparison, a const object and its fields cannot be changed: they’re immutable.
Code 11:
void main(){ const int a=10; a=20; print(a); const String b=”windows 11″; b=”linux”; print(b); } |

code 12:
void main(){ const var a=25; a=90; print(a); const var c=89.67; c=90.8; print(c); } |
