Dart basic -1

Sachin Jat
VirtouStack
5 min readMay 30, 2022

--

what is Dart?

Dart is an open-source general-purpose programming language developed by Google. It supports application development in both client and server-side. But it is widely used for the development of android apps, iOS apps, IoT(Internet of Things), and web applications using the Flutter Framework.

It is meant for both server side as well as the user side.

The Dart SDK comes with its compiler — the Dart VM and a utility dart2js which is meant for generating Javascript equivalent of a Dart Script so that it can be run on those sites also which don’t support Dart.

Dart is Object-oriented language and is quite similar to that of Java Programming. Dart is extensively use to create single-page websites and web-applications. Best example of dart application is Gmail.

my first program with dart

void main() {
print(‘Hello World!’);
}

Dart Comments

In every programming language comments play an important role for a better understanding of the code in the future or by any other programmer. Comments are a set of statements that are not meant to be executed by the compiler. They provide proper documentation of the code.

Types of Dart Comments:

  1. Dart Single line Comment.
  2. Dart Multiline Comment.
  3. Dart Documentation Comment.

Dart Single line Comment: Dart single line comment is used to comment a line until line break occurs. It is done using a double forward-slash (//).

Dart Multi-Line Comment: Dart Multiline comment is used to comment out a whole section of code. It uses ‘/*’ and ‘*/’ to start and end a multi-line comment respectively.

Dart Documentation Comment: Dart Documentation Comments are a special type of comment used to provide references to packages, software, or projects. Documentation comments “///”(C# Style)

Dart Variables

A variable name is the name assign to the memory location where the user stores the data and that data can be fetched when required with the help of the variable by calling its variable name. There are various types of variable which are used to store the data. The type which will be used to store data depends upon the type of data to be stored.

Conditions to write variable name or identifiers :

  1. Variable name or identifiers can’t be the keyword.
  2. Variable name or identifiers can contain alphabets and numbers.
  3. Variable name or identifiers can’t contain spaces and special characters, except the underscore(_) and the dollar($) sign.
  4. Variable name or identifiers can’t begin with number.

Dart Data Types

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.

Dart supports the following built-in Data types.

  • Number
  • Strings
  • Boolean
  • Lists
  • Maps
  • Runes
  • Symbols

Dart Number

The Darts Number is used to store the numeric values. The number can be two types — integer and double.

  • Integer — Integer values represent the whole number or non-fractional values. An integer data type represents the 64-bit non-decimal numbers between -263 to 263. A variable can store an unsigned or signed integer value. The example is given below -

int marks = 1;

  • Double — Double value represents the 64-bit of information (double-precision) for floating number or number with the large decimal points. The double keyword is used to declare the double type variable.

double pi = 12.23;

Dart Strings

A string is the sequence of the character. If we store the data like — name, address, special character, etc. It is signified by using either single quotes or double quotes. A Dart string is a sequence of UTF-16 code units.

  1. String msg = “first dart string”;

Dart Boolean

The Boolean type represents the two values — true and false. The bool keyword uses to denote Boolean Type. The numeric values 1 and 0 cannot be used to represent the true or false value.

  1. bool isTrue = true;

Dart Lists

In Dart, The list is a collection of the ordered objects (value). The concept of list is similar to an array. An array is defined as a collection of the multiple elements in a single variable. The elements in the list are separated by the comma enclosed in the square bracket[]. The sample list is given below.

  1. List list = [1,2,3]

Dart Maps

The maps type is used to store values in key-value pairs. Each key is associated with its value. The key and value can be any type. In Map, the key must be unique, but a value can occur multiple times. The Map is defined by using curly braces ({}), and comma separates each pair.

  1. Map student = {‘name’: ‘sachin’, ‘age’:22, ‘Branch’: ‘Computer Science’}

Dart Runes

As we know that, the strings are the sequence of Unicode UTF-16 code units. Unicode is a technique which is used to describe a unique numeric value for each digit, letter, and symbol. Since Dart Runes are the special string of Unicode UTF-32 units. It is used to represent the special syntax.

--

--