Chapter 2 Flutter Basics Lecture 1
Chapter 2 Flutter Basics Lecture 1
Despite its many advantages, flutter has the following drawbacks in it:
Since it is coded in Dart language, a developer needs to learn new
language (though it is easy to learn).
Modern framework tries to separate logic and UI as much as possible but,
in Flutter, user interface and logic is intermixed. We can overcome this
using smart coding and using high level module to separate user interface
and logic.
Flutter is yet another framework to create mobile application. Developers
are having a hard time in choosing the right development tools in hugely
populated segment.
FLUTTER THE DART PROGRAMMING
void main() {
print("Dart language is easy to
learn");
VARIABLES AND DATA TYPES
Variable is named storage location and Data types simply refers to the
type and size of data associated with variables and functions. Dart uses
var keyword to declare the variable.
The syntax of var is defined below
Dynamic: If the variable type is not defined, then its default type is
dynamic. The following example illustrates the dynamic type variable:
void main() {
dynamic name = "Dart";
print(name);
}
DART CONTROL FLOW STATEMENT
The control statements or flow of control statements are used to
control the flow of Dart program. These statements are very important in
any programming languages to decide whether other statement will be
executed or not. The code statement generally runs in the sequential
manner. We may require executing or skipping some group of statements
based on the given condition, jumps to another statement, or repeat the
execution of the statements.
In Dart, control statement allows to smooth flow of the program. By using
the control flow statements, a Dart program can be altered, redirected, or
repeated based on the application logic.
CATEGORIES OF FLOW STATEMENT
Dart looping statements are used to execute the block of code multiple-
times for the given number of time until it matches the given condition.
These statements are also called Iteration statement.
Dart provides following types of the looping statements. for(int i = 1; i < =1
do{
Dart 0;i++)
for loop print(i);
{
i++;
Dart for….in loop }while(i<=20); print(i);
print("The loop is terminate }
Dart while loop var list1 = [10,20,30,40,
d"); int i = 1; 50];
Dart do while loop while (i <= 5 for(var i in list1) {
) print(i);
bool check; { }
check = 20>10; print( i);
print("The statement is = $ ++i;
{check}");
DART JUMP STATEMENTS
Jump statements are used to jump from another statement, or we can say
that it transfers the execution to another statement from the current
statement.
Dart provides following types of jump statements -
Dart Break Statement
Dart Continue Statement
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.
The syntax of the class is given below.
class ClassName {
<fields>
<getter/setter>
<constructor>
<functions>
}
OBJECT
An object is a real-life entity such as a table, human, car, etc. The object
has two characteristics - state and behavior. Let's take an example of a car
which has a name, model name, price and behavior moving, stopping, etc.
The object-oriented programming offers to identify the state and behavior
of the object.
We can access the class properties by creating an object of that class. In
Dart, The object can be created by using a new keyword followed by class
name. The syntax is given below.