• Guides
    • Getting started with Dart
  • Blog
  • FAQ
    • Dart
    • Flutter
  • Contact
  • Guides
    • Getting started with Dart
  • Blog
  • FAQ
    • Dart
    • Flutter
  • Contact
  • Getting Started with Dart
    • Dart Variables
    • Dart Operators
    • Dart Comments
  • Dart Data Types
    • Dart Strings
    • Dart Numbers
    • Dart Booleans
    • Dart Lists
    • Dart Maps
  • Control Flow
    • Dart if...else Statements
    • Dart switch Statement
    • Dart for Loop
    • Dart for...in Loop
    • Dart while and do...while Loops
    • break and continue Statements
  • Dart Functions
  • Dart Classes
  • Dart Objects
  • Dart Constructors
  • Dart Exceptions

Dart Data Types

325 views 2

Written by fawesomeapps
December 7, 2021

In this chapter, we will learn about different Data Types that are available in dart.


Dart Data Types

Different data types are available in dart. For example,

String name = ‘Phil’;

int number = 22;

Here,

‘Phil’ is string data.

22 is integer data.

Dart has the following data types:

Data TypesDescriptionKeyword
StringsSequence of textual charactersString
NumbersInteger or floating point numberint, double, num
BooleansValues true and  falsebool
Listsset of objectsList
MapsSet of value of key/value pairsMap

Dart Strings

String refers to the collection of characters. In dart, strings are enclosed in either single quotes or double quotes. The keyword String is used to represent string value.

For example,

String name = ‘Phil’;

String name = ‘Lauren’;

Dart Numbers

Numbers represent integer values and floating values. For integer values, keyword int is used. And for floating values, keyword double is used. The num keyword represents numbers in general.

For example,

int value1 = 35;

double value2 = 35.89;

num value3 = 35.89;

num value4 = 35;

Dart Booleans

Boolean values represent true and false. The bool keyword is used to denote boolean values.

For example,

bool isValue = true;

bool count = false;

Dart Lists

In dart, the list represents a collection of objects/values. We can create a list data type by enclosing the values in square braces. For example,

var numbers = [4, 8, 2.4, 5];

Another way to create a list is by passing the new keyword to the List object. For example,

List names = new List();

Dart Maps

In dart, maps denote a collection of data in key/value pairs. The key and value can be of any data type. We can create a map data type by enclosing the value in curly braces and separating each pair by comma. For example,

var person = {‘name’: ‘Phil’, ‘age’: 25, isMale: true}

Another way to create map data is by passing the new keyword to the Map object. For example,

Map person = new Map();

In map data types, keys must be unique.

Was this helpful?

2 Yes  1 No
Related Articles
  • Dart Constructors
  • Dart Exceptions
  • Dart Objects
  • Dart Classes
  • Control Flow
  • Dart Functions
Previously
Dart Comments
Up Next
Dart Strings
flutter-dev-experts




FLUTTERGUIDE
FlutterGuide is an easy learning guide platform to help you build apps for any screen. The leading Dart/Flutter guides for getting started and become pro.
Guides
  • Getting started with Dart 22
  • Private Documentation 1
Categories
  • Firebase
  • Dart
  • iOS
  • API
  • Bloc
  • Flutter
  • Widgets
  • Mobile
  • State Management
  • Design
  • Animations
  • Flutter Designs
About
About Us
Guides
Blogs
FAQs
Contact
  • Privacy Policy
  • Terms & Conditions
  • Copyright 2022 Fawesome Apps. All Rights Reserved