What is Built-in Variables in Dart

In this article you will learn about Built-in Variables in Dart Language.
  • 1974

built-in type in dart language

Dart language support different built-in type, some of them is given below-

  • String

    A dart string is a collection of characters.

Example of String

void main() {
  var str1='This is single quotes string';
  var str2 =" This is a double quotes string";
  print('${str1}');
  print("${str2}");

}


Output

 str.png

  • Number

    Dart number are two type-

  1. int

    Integer number contains integer value without decimal value.
     

  2. double

    In double contains both integer and decimal value, basically it used for a large value.

Example of number
 

void main() {
  int val=1;
  // int val2=1.1  // Error
  print('$val');

var
bigInt=1111111111111.11111111111111111111111111111111111111111;
var
bigInt1=433453543655467576878799870932143434367576576767676767;
  print('$bigInt');
  print('$bigInt1');

}


Output

integer.png

  • Boolean

    Dart  has boolean type, named bool. It  have two values; true or false .

Example of boolean
 

void main()

{

  var name='     ';

if(name.isEmpty()){

  print("True");

}

else{

  print("false");

}

}


Output

bool.png
  • Lists

    Lists are also known as arrays or say list is a collection of elements.

Example of lists
 

void main()

{

var list =[1,2,3];

print('$list');

}


Output

 list.png

  • Maps
    A map is an object associates keys two values.

Example of maps
 

void main()

{

var maps={

         "one":"B",

         "two":"C",

         "three":"C++" };

var values=maps.getKeys();
values.forEach((g) => print(g));

}


Output

 maps.png

Ask Your Question 

Got a programming related question? You may want to post your question here
 
© 2019 DotNetHeaven. All rights reserved.