0% found this document useful (0 votes)
24 views70 pages

Dart

Uploaded by

islamtasnim65
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views70 pages

Dart

Uploaded by

islamtasnim65
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 70

DART

Dart is a client-optimized language


for fast apps on any platform
80

60

YOUR
UNDERSTANDING 40

Will Increase gradually

20

0
Level 1 Level 2 Level 3 Level 4 Level 5 Level 6 Level 7
BEGINNER STAGE
Don’t Dive Deep When You Are
Beginner
DART
Environment Setup https://dartpad.dartlang.org

https://gekorm.com/dart-windows

https://www.jetbrains.com/idea/download
MY FIRST
Dart Program

The main() function is a predefined method in Dart.


This method acts as the entry point to the application.
DART SYNTAX
Syntax is called set of rules for writing programs. Dart has-

Variables and Operators

Classes

Functions

Expressions and Programming Constructs

Decision Making and Looping Constructs

Comments

Libraries and Packages

Data structures represented as Collections / Generics


DART SYNTAX
Whitespace and Line Breaks
Dart ignores spaces, tabs, and newlines that appear in programs.

Dart is Case-sensitive
Dart is case-sensitive. This means that Dart differentiates between uppercase and
lowercase characters

Statements end with a Semicolon


Each line of instruction is called a statement. Each dart statement must
end with a semicolon

Comments in Dart
Single-line comments ( // ) Multi-line comments (/* */)
DART KEYWORDS
DART KEYWORDS
DART VARIABLE
Variable is used to store the value and refer the memory location in computer memory.

The variable cannot contain special characters such as whitespace, mathematical symbol, runes,

Unicode character, and keywords.

The first character of the variable should be an alphabet([A to Z],[a to z]). Digits are not allowed as the

first character.

Variables are case sensitive. For example, - variable age and AGE are treated differently.

The special character such as #, @, ^, &, * are not allowed expect the underscore(_) and the dollar

sign($).

The variable name should be retable to the program and readable.


DART DATA TYPES
Number Maps
Strings Runes
Boolean Symbols
Lists
DART NUMBER
Integer
Integer values represent the whole number or
non-fractional values.

Double
Double value represents the floating number
or number with the large decimal points.
DART STRING
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.
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.
DART LISTS
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[].
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.
DART OPERATORS
(Arithmetic Operators)
DART OPERATORS
(Arithmetic Operators)
DART OPERATORS
(Unary Operators)
DART OPERATORS
(Unary Operators)
DART OPERATORS
(Assignment Operator)
DART OPERATORS
(Relational Operator)
DART OPERATORS
(Type Test Operators)
DART OPERATORS
(Logical Operators)
DART OPERATORS
(Bitwise Operators)
DART CONSTANTS
Dart Constant is defined as an immutable object
Which means it can't be changed or modified during the execution of the program.
Once we initialize the value to the constant variable, it cannot be reassigned later.

The Dart constant can be defined in the following two ways.


Using the final keyword
Using the const keyword
DART CONSTANTS
Dart Constant is defined as an immutable object
Which means it can't be changed or modified during the execution of the program.
Once we initialize the value to the constant variable, it cannot be reassigned later.

The Dart constant can be defined in the following two ways.


Using the final keyword
Using the const keyword
LIST PROPERTIES
FIXED LENGTH LIST
The fixed-length lists are defined with the specified length.

We cannot change the size at runtime.


GROWABLE LIST
The list is declared without specifying size is known as a Grow able list.

The size of the Grow able list can be modified at the runtime.
LIST INSERT
Dart provides four methods which are
used to insert the elements into the
lists. These methods are given below.

add()
addAll()
insert()
insertAll()
UPDATING LIST REMOVING LIST ELEMENTS
list_name[index] = new_value remove() removeAt() removeLast() removeRange()
DART SET
The Dart Set is the unordered collection of the
different values of the same type

It has much functionality, which is the same


as an array, but it is unordered.

Set doesn't allow storing the duplicate values.

Set must contain unique values.


ADD ELEMENT INTO SET
The Dart provides the two methods add() and addAll() to insert an element into the given set.
ACCESS THE SET ELEMENT
Dart provides the elementAt() method, which is used to access the item by passing
its specified index position.
DART REMOVE ALL SET ELEMENT
We can remove entire set element by using the clear() methods.
DART SET PROPERTIES
DART MAP
Dart Map is an object that stores data in the form of a key-value pair.

Each value is associated with its key, and it is used to access its corresponding value.

Both keys and values can be any type.

In Dart Map, each key must be unique, but the same value can occur multiple times.

Dart Map can be defined in two methods.

Using Map Literal

Using Map Constructor


DART MAP USING MAP LITERAL
To declare a Map using map literal, the key-value pairs are enclosed within
the curly braces "{}" and separated by the commas.
ADDING VALUE AT RUNTIME
To declare a Map using map literal, the key-value pairs are enclosed within
the curly braces "{}" and separated by the commas.
USING MAP CONSTRUCTOR
To declare the Dart Map using map constructor can be done in two ways.

First, declare a map using map() constructor. Second, initialize the map.
MAP PROPERTIES
MAP METHODS
addAll() - It adds multiple key-value pairs of other. The syntax is given below.

Map.clear() - It eliminates all pairs from the map.


MAP METHODS
remove() - It removes the key and its associated value if it exists in the given map.
DART CONTROL FLOW STATEMENT
The control statements or flow of control statements are used to control the flow of Dart
program. In Dart, Control flow statement can be categorized mainly in three following ways.

Decision-making statements

Looping statements

Jump statements
DART DECISION-MAKING STATEMENTS
The Decision-making statements allow us to determine which statement to execute based
on the test expression at runtime. Dart provides following types of Decision-making
statement.

If Statement

If-else Statements

If else if Statement

Switch Case Statement


IF STATEMENT
If statement allows us to a block of code execute when the given condition returns true.

IF-ELSE STATEMENTS
In Dart, if-block is executed when the given condition is true. If the given condition is false, else-block is executed.
IF ELSE-IF STATEMENT
Dart if else-if statement provides the facility to check a set
of test expressions and execute the different statements.
It is used when we have to make a decision from more
than two possibilities.

SWITCH CASE STATEMENT


Dart Switch case statement is used to avoid the long chain
of the if-else statement.
It is the simplified form of nested if-else statement.
DART LOOPING STATEMENTS
Dart Loop is used to run a block of code repetitively for a given number of times or until matches the
specified condition.

Dart for loop

Dart for…in loop

Dart while loop

Dart do-while loop


DART FOR LOOP
The for loop is used when we know how many times a block of code will execute.

DART FOR… IN LOOP OVER LIST


The for…in loop is slightly different from the for loop. It only takes dart object or expression as an iterator and iterates the
element one at a time.
DART FOR… IN LOOP OVER MAP (JSON ARRAY)

DART FOR… IN LOOP OVER SET


FUNCTION PARTS
return_type - It can be any data type such as void, integer, float,
etc. The return type must be matched with the returned value of
the function.

func_name - It should be an appropriate and valid identifier.

parameter_list - It denotes the list of the parameters, which is


necessary when we called a function.

return value - A function returns a value after complete its


execution.
FUNCTION PARTS
return_type - It can be any data type such as void, integer, float,
etc. The return type must be matched with the returned value of
the function.

func_name - It should be an appropriate and valid identifier.

parameter_list - It denotes the list of the parameters, which is


necessary when we called a function.

return value - A function returns a value after complete its


execution.
DEFINING A FUNCTION
A function can be defined by providing the name of the function with the appropriate parameter and return type.
A function contains a set of statements which are called function body.

CALLING A FUNCTION
After creating a function, we can call or invoke the defined function inside the main() function body
PASSING ARGUMENTS TO
FUNCTION
When a function is called, it may have some information as per
the function prototype is known as a parameter (argument).
FUNCTION RETURN & RETURN TYPE
It can be any data type such as void, integer, float, etc. The
return type must be matched with the returned value of the
function.

A function returns a value after complete its execution.


THE MAIN() FUNCTION
The main() function is the top-level function of the Dart.
It is the most important and vital function of the Dart programming language.
The execution of the programming starts with the main() function.
The main() function can be used only once in a program.
FUNCTION RECURSION
Dart Recursion is the method where a function calls itself as its subroutine.

It is used to solve the complex problem by dividing it into sub-part.

A function which is called itself again and again or recursively, then this process is called recursion
DART OBJECT-ORIENTED CONCEPTS
Dart is an object-oriented programming language, and it supports all the concepts of object-oriented programming such
as classes, object, inheritance, mixin, and abstract classes.

Class
Object
Inheritance
Polymorphism
Interfaces
Abstract class
DART CLASS
Dart classes are defined as the blueprint of the associated objects.
A Class is a user-defined data type that describes the characteristics and behavior of it.
To get all properties of the class, we must create an object of that class.
ACCESSING VARIABLE ACCESSING FUNCTION
FROM CLASS FROM CLASS
ACCESSING STATIC ACCESSING STATIC
VARIABLE FROM CLASS FUNCTION FROM CLASS
CLASS CONSTRUCTOR
A constructor is a different type of function which is created with same name as its class name.
The constructor is used to initialize an object when it is created.

Constructor has no return type


Constructor can have parameter
Constructor execute automatically
DART THIS KEYWORD
The this keyword is used to refer the current class object.
It indicates the current instance of the class, methods, or constructor.
DART INHERITANCE
Dart inheritance is defined as the process of deriving the

properties and characteristics of another class.

It provides the ability to create a new class from an existing class.

It is the most essential concept of the oops(Object-Oriented

programming approach).

We can reuse the all the behavior and characteristics of the

previous class in the new class.

Parent Class:
A class which is inherited by the other class is called
superclass or parent class. It is also known as a base
class.

Child Class:
A class which inherits properties from other class is called
the child class. It is also known as the derived class or
subclass.
METHOD OVERRIDING
When we declare the same method in the subclass, which is previously

defined in the superclass is known as the method overriding.

The subclass can define the same method by providing its own

implementation, which is already exists in the superclass.

The method in the superclass is called method overridden, and method

in the subclass is called method overriding.


DART ABSTRACT CLASSES
Abstract classes are the classes in Dart that has one or more abstract

method.

Abstraction is a part of the data encapsulation where the actual internal

working of the function hides from the users.

They interact only with external functionality.

We can declare the abstract class by using the abstract keyword.

There is a possibility that an abstract class may or may not have

abstract methods.
DART IMPORT CODE FORM EXTERNAL FILES
DART DEBUGGING
WHY DEBUGGING IS IMPORTANT

To find out my mistake

To test/check my code , that works well

To understand complex program flow

To works with complex action part by part

To improve my code

You might also like