In addition to general data types such as String, integer, we use different; We will talk about 2 important data types.

  • var
  • dynamic

The var data type does not have a specific value. We can assign any variable we want, it doesn’t matter. You can give a string or an integer value if you wish, to the variable defined by var. You can see examples below.

var name = 'Baransel Arslan';
var age = 20;
var message = 'Welcome! $name';
var message2 = 'Welcome! ${name.toUpperCase()}';

The dynamic data type has a mutable structure. We can define the variable we created with dynamic in the first string data type and then assign an integer value to the same variable. Of course, I use this string and integer example all the time because they are the most common variable types. Variables such as double, bool can also be used.

dynamic variable = 'Baransel Arslan';
variable = 20;