Skip to content
Related Articles

Related Articles

Dart – Data Types

View Discussion
Improve Article
Save Article
  • Difficulty Level : Basic
  • Last Updated : 14 Jul, 2020

Like other languages (C, C++, Java), whenever a variable is created, each variable has an associated data type. In Dart language, there is the type of values that can be represented and manipulated in a programming language. The data type classification is as given below: 

Data TypeKeywordDescription
Numberint, double, numNumbers in Dart are used to represent numeric literals
StringsStringStrings represent a sequence of characters
BooleansboolIt represents Boolean values true and false
ListsListIt is an ordered group of objects
MapsMapIt represents a set of values as key-value pairs

1. Number: The number in Dart Programming is the data type that is used to hold the numeric value. Dart numbers can be classified as: 

  • The int data type is used to represent whole numbers.
  • The double data type is used to represent 64-bit floating-point numbers.
  • The num type is an inherited data type of the int and double types.


void main() {
   // declare an integer
   int num1 = 2;             
   // declare a double value
   double num2 = 1.5;  
   // print the values
   var a1 = num.parse("1");  
   var b1 = num.parse("2.34");  
   var c1 = a1+b1;   
   print("Product = ${c1}"); 



Product = 3.34

2. String: It used to represent a sequence of characters. It is a sequence of UTF-16 code units. The keyword string is used to represent string literals. String values are embedded in either single or double-quotes. 


void main() {
    String string = 'Geeks''for''Geeks'
    String str = 'Coding is '
    String str1 = 'Fun'
    print (string);  
    print (str + str1);



Coding is Fun

3. Boolean: It represents Boolean values true and false. The keyword bool is used to represent a Boolean literal in DART. 


void main() {
  String str = 'Coding is '
  String str1 = 'Fun'
  bool val = (str==str1);
  print (val);  




4. List: List data type is similar to arrays in other programming languages. A list is used to represent a collection of objects. It is an ordered group of objects. 


void main() 
    List gfg = new List(3); 
    gfg[0] = 'Geeks'
    gfg[1] = 'For'
    gfg[2] = 'Geeks'



[Geeks, For, Geeks]

5. Map: The Map object is a key and value pair. Keys and values on a map may be of any type. It is a dynamic collection. 


void main() { 
  Map gfg = new Map(); 
  gfg['First'] = 'Geeks'
  gfg['Second'] = 'For'
  gfg['Third'] = 'Geeks';



{First: Geeks, Second: For, Third: Geeks}

Note: If the type of a variable is not specified, the variable‚Äôs type is dynamic. The dynamic keyword is used as a type annotation explicitly.

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!