Dart Language Data Type
In this blog, we are going the explore the basic data types in the dart programming language. let’s see what we get out of the box.
Like other languages (C, C++, Java), whenever a variable is created, each variable has an associated data type. In Dart language, there are the types of values that can be represented and manipulated in a programming language.
In this article, we will learn about Dart Programming Language Data Types.
Data Types in Dart
The data type classification is as given below:
Number
Strings
Get mohammed sherif’s stories in your inbox
Join Medium for free to get updates from this writer.
Booleans
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:
- int: data type is used to represent whole numbers (64-bit Max).
- double: data type is used to represent 64-bit precise floating-point numbers.
- num: type is an inherited data type of the int and double types.
Below is the implementation of Numbers in Dart:
// Dart Program to demonstrate
// Number Data Type
void main() {
// declare an integer
int num1 = 2;
// declare a double value
double num2 = 1.5;
// print the values
print(num1);
print(num2);
var a1 = num.parse("1");
var b1 = num.parse("2.34");
var c1 = a1+b1;
print("Product = ${c1}");
}
// Output:
/* 2
1.5
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.
Syntax:
// String str_name;Below is the implementation of String data type in Dart:
// Dart Program to demonstrate
// String Data Type
// Driver Class
void main() {
// Declaration of String type
String string = 'Hello Word Form Flutter';
String str = 'Coding is ';
String str1 = 'Fun';
print (string);
print (str + str1);
}
// Output:
/*
Hello Word Form Flutter
Coding in Fun
*/
3. Boolean
It represents Boolean values true and false. The keyword bool is used to represent a Boolean literal in DART.
Syntax:
bool var_name;// Dart Program to demonstrate
// Boolean Data Type
void main() {
String str = 'Coding is ';
String str1 = 'Fun';
bool val = (str==str1);
print (val);
}
// Output
/*
false
*/
Conclusion
Dart is a programming language used to develop Flutter applications. It’s an excellent option for building mobile apps on multiple platforms. I’ve previously written tutorial articles on Flutter widgets and plan to continue doing so. However, I also want to write about Dart programming, starting with the basics to help absolute beginners. This tutorial series will begin with Data Types and Variables, which are essential building blocks of any programming language.





