KEMBAR78
Chapter 2 Flutter Basics Lecture 1.pptx
CHAPTER 2 FLUTTER BASICS LECTURE 1
INTRODUCTION TO FLUTTER AND DART PROGRAMING LANGUAGE
INTRODUCTION TO FLUTTER
 Flutter is an open source framework to create high quality, high performance
mobile applications across mobile operating systems - Android and iOS. It
provides a simple, powerful, efficient and easy to understand SDK to write
mobile application in Google’s own language, Dart.
 Flutter also offers many ready to use widgets (UI) to create a modern
application. These widgets are optimized for mobile environment and
designing the application using widgets is as simple as designing HTML.
FEATURES OF FLUTTER
 Flutter framework offers the following features to developers:
 Modern and reactive framework.
 Uses Dart programming language and it is very easy to learn.
 Fast development.
 Beautiful user interfaces.
 Huge widget catalog.
 Runs same UI for multiple platforms.
 High performance application.
ADVANTAGES OF FLUTTER
Flutter comes with beautiful and customizable widgets for high performance
and outstanding mobile application. It fulfills all the custom needs and
requirements. Besides these, Flutter offers many more advantages as mentioned
below:
 Dart has a large repository of software packages which lets you to extend the
capabilities of your application.
 Developers need to write just a single code base for both applications (both
Android and iOS platforms). Flutter may to be extended to other platform as well
in the future.
CONT..
 Flutter needs lesser testing. Because of its single code base, it is sufficient if
we write automated tests once for both the platforms.
 Flutter’s simplicity makes it a good candidate for fast development. Its
customization capability and extendibility makes it even more powerful.
 With Flutter, developers has full control over the widgets and its layout.
 Flutter offers great developer tools, with amazing hot reload.
DISADVANTAGES OF FLUTTER
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
Dart is an open-source general-purpose programming language. It is originally
developed by Google. Dart is an object-oriented language with C-style syntax. It
supports programming concepts like interfaces, classes, unlike other programming
languages Dart doesn’t support arrays. Dart collections can be used to replicate data
structures such as arrays, generics, and optional typing.
The following code shows a simple Dart program:
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
 The final and const keyword are used to declare constants. They are defined as
below:
var name = 'Dart’;
void main() {
final a = 12;
const pi = 3.14;
print(a);
print(pi);
}
CONT..
Dart language supports the following data types:
 Numbers: It is used to represent numeric literals – Integer and Double.
 Strings: It represents a sequence of characters. String values are specified in either
single or double quotes.
 Booleans: Dart uses the bool keyword to represent Boolean values – true and false.
 Lists and Maps: It is used to represent a collection of objects.
A simple List can be defined as below: void main() {
var list = [1,2,3,4,5];
print(list);
}
CONT..
 The list shown above produces [1,2,3,4,5] list.
 Map can be defined as shown here:
 Dynamic: If the variable type is not defined, then its default type is dynamic. The
following example illustrates the dynamic type variable:
void main() {
var mapping = {'id': 1,'name':'Dart’};
print(mapping);
}
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
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. Decision-making
statements are also known as the Selection
statements. In Dart program, single or multiple
test expression (or condition) can be existed,
which evaluates Boolean TRUE and FALSE. These
results of the expression/condition helps to
decide which block of statement (s) will execute if
the given condition is TRUE or FALSE.
CONT..
Dart provides following types of Decision-making statement.
• If Statement
• If-else Statements
• If else if Statement
• Switch Case Statement
if (n<40){
print("The number is smaller than 40"
)
};
if(x > y){
print("x is greater than y");
} else {
print("y is greater than x");
};
if(marks > 85)
{
print("Excellent");
}
else if(marks>75)
{
print("Very Good");
}
else
{
print("Average");
}
switch (n) {
case 1:
print("Value is 1");
break;
default:
print("Out of range");
break;
DART LOOPING STATEMENTS
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.
 Dart for loop
 Dart for….in loop
 Dart while loop
 Dart do while loop
for(int i = 1; i < =10;i++
)
{
print(i);
}
var list1 = [10,20,30,40,50];
for(var i in list1) {
print(i);
}
int i = 1;
while (i <= 5)
{
print( i);
++i;
}
do{
print(i);
i++;
}while(i<=20);
print("The loop is terminated");
bool check;
check = 20>10;
print("The statement is = ${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
The above jump statements behave differently.
DART FUNCTION
 Dart function is a set of codes that together perform a specific task. It is used to
break the large code into smaller modules and reuse it when needed. Functions make
the program more readable and easy to debug. It improves the modular approach
and enhances the code reusability.
void main()
{
add(3,4);
}
void add(int a,int b)
{
int c;
c = a + b;
print(c);
}
ADVANTAGES OF FUNCTIONS
 The few benefits of the Dart function is given below.
 It increases the module approach to solve the problems.
 It enhances the re-usability of the program.
 We can do the coupling of the programs.
 It optimizes the code.
 It makes debugging easier.
 It makes development easy and creates less complexity.
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. As the name suggests, it focuses on the object and objects are the real-life entities.
The Object-oriented programming approach is used to implement the concept like
polymorphism, data-hiding, etc. The main goal of oops is to reduce programming
complexity and do several tasks simultaneously. The oops concepts are given below.
• Class
• Object
• Inheritance
• Polymorphism
• Interfaces
• Abstract class
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. 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.
var objectName = new ClassName(<constructor_arguments>)
INHERITANCE
 Dart supports inheritance, which is used to create new classes from an existing class.
The class that to be extended is called parent /superclass, and the newly created class
is called child/subclass.
 Dart provides extends keyword to inherit the properties of parent class in child class.
The syntax is given below.
class child_class_name extends parent_class_name
POLYMORPHISM
 Polymorphism is an object-oriented programming concept where one thing has
many forms. It can be two types - Runtime polymorphism and Compile time
polymorphism.
 For example - A function has the same name but with a different behavior or class.
 Another example is the shape() class, and all the class inherited from the Rectangle,
Triangle, and circle.
INTERFACES
 The interface is defined as a blueprint of the class. We can declare methods and
variables inside the interface just like the class but in interface only abstract
declaration of methods is provided.
 We can only define the function signature but not its body.
 Another class can implement the interface. It is basically used for data-hiding.
ABSTRACT CLASS
 A class that contains one or more abstract method is called an abstract class. We can
declare the abstract class using the abstract keyword followed by class declaration.
The syntax is given below.
abstract class ClassName {
//Body of abstract class
}
END OF THE CHAPTER

Chapter 2 Flutter Basics Lecture 1.pptx

  • 1.
    CHAPTER 2 FLUTTERBASICS LECTURE 1 INTRODUCTION TO FLUTTER AND DART PROGRAMING LANGUAGE
  • 2.
    INTRODUCTION TO FLUTTER Flutter is an open source framework to create high quality, high performance mobile applications across mobile operating systems - Android and iOS. It provides a simple, powerful, efficient and easy to understand SDK to write mobile application in Google’s own language, Dart.  Flutter also offers many ready to use widgets (UI) to create a modern application. These widgets are optimized for mobile environment and designing the application using widgets is as simple as designing HTML.
  • 3.
    FEATURES OF FLUTTER Flutter framework offers the following features to developers:  Modern and reactive framework.  Uses Dart programming language and it is very easy to learn.  Fast development.  Beautiful user interfaces.  Huge widget catalog.  Runs same UI for multiple platforms.  High performance application.
  • 4.
    ADVANTAGES OF FLUTTER Fluttercomes with beautiful and customizable widgets for high performance and outstanding mobile application. It fulfills all the custom needs and requirements. Besides these, Flutter offers many more advantages as mentioned below:  Dart has a large repository of software packages which lets you to extend the capabilities of your application.  Developers need to write just a single code base for both applications (both Android and iOS platforms). Flutter may to be extended to other platform as well in the future.
  • 5.
    CONT..  Flutter needslesser testing. Because of its single code base, it is sufficient if we write automated tests once for both the platforms.  Flutter’s simplicity makes it a good candidate for fast development. Its customization capability and extendibility makes it even more powerful.  With Flutter, developers has full control over the widgets and its layout.  Flutter offers great developer tools, with amazing hot reload.
  • 6.
    DISADVANTAGES OF FLUTTER Despiteits 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.
  • 7.
    FLUTTER THE DARTPROGRAMMING Dart is an open-source general-purpose programming language. It is originally developed by Google. Dart is an object-oriented language with C-style syntax. It supports programming concepts like interfaces, classes, unlike other programming languages Dart doesn’t support arrays. Dart collections can be used to replicate data structures such as arrays, generics, and optional typing. The following code shows a simple Dart program: void main() { print("Dart language is easy to learn"); }
  • 8.
    VARIABLES AND DATATYPES  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  The final and const keyword are used to declare constants. They are defined as below: var name = 'Dart’; void main() { final a = 12; const pi = 3.14; print(a); print(pi); }
  • 9.
    CONT.. Dart language supportsthe following data types:  Numbers: It is used to represent numeric literals – Integer and Double.  Strings: It represents a sequence of characters. String values are specified in either single or double quotes.  Booleans: Dart uses the bool keyword to represent Boolean values – true and false.  Lists and Maps: It is used to represent a collection of objects. A simple List can be defined as below: void main() { var list = [1,2,3,4,5]; print(list); }
  • 10.
    CONT..  The listshown above produces [1,2,3,4,5] list.  Map can be defined as shown here:  Dynamic: If the variable type is not defined, then its default type is dynamic. The following example illustrates the dynamic type variable: void main() { var mapping = {'id': 1,'name':'Dart’}; print(mapping); } void main() { dynamic name = "Dart"; print(name); }
  • 11.
    DART CONTROL FLOWSTATEMENT  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.
  • 12.
    CATEGORIES OF FLOWSTATEMENT In Dart, Control flow statement can be categorized mainly in three following ways. • Decision-making statements • Looping statements • Jump statements
  • 13.
    DART DECISION-MAKING STATEMENTS The Decision-making statements allow us to determine which statement to execute based on the test expression at runtime. Decision-making statements are also known as the Selection statements. In Dart program, single or multiple test expression (or condition) can be existed, which evaluates Boolean TRUE and FALSE. These results of the expression/condition helps to decide which block of statement (s) will execute if the given condition is TRUE or FALSE.
  • 14.
    CONT.. Dart provides followingtypes of Decision-making statement. • If Statement • If-else Statements • If else if Statement • Switch Case Statement if (n<40){ print("The number is smaller than 40" ) }; if(x > y){ print("x is greater than y"); } else { print("y is greater than x"); }; if(marks > 85) { print("Excellent"); } else if(marks>75) { print("Very Good"); } else { print("Average"); } switch (n) { case 1: print("Value is 1"); break; default: print("Out of range"); break;
  • 15.
    DART LOOPING STATEMENTS Dartlooping 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.  Dart for loop  Dart for….in loop  Dart while loop  Dart do while loop for(int i = 1; i < =10;i++ ) { print(i); } var list1 = [10,20,30,40,50]; for(var i in list1) { print(i); } int i = 1; while (i <= 5) { print( i); ++i; } do{ print(i); i++; }while(i<=20); print("The loop is terminated"); bool check; check = 20>10; print("The statement is = ${check}");
  • 16.
    DART JUMP STATEMENTS Jumpstatements 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 The above jump statements behave differently.
  • 17.
    DART FUNCTION  Dartfunction is a set of codes that together perform a specific task. It is used to break the large code into smaller modules and reuse it when needed. Functions make the program more readable and easy to debug. It improves the modular approach and enhances the code reusability. void main() { add(3,4); } void add(int a,int b) { int c; c = a + b; print(c); }
  • 18.
    ADVANTAGES OF FUNCTIONS The few benefits of the Dart function is given below.  It increases the module approach to solve the problems.  It enhances the re-usability of the program.  We can do the coupling of the programs.  It optimizes the code.  It makes debugging easier.  It makes development easy and creates less complexity.
  • 19.
    DART OBJECT-ORIENTED CONCEPTS Dartis an object-oriented programming language, and it supports all the concepts of object-oriented programming such as classes, object, inheritance, mixin, and abstract classes. As the name suggests, it focuses on the object and objects are the real-life entities. The Object-oriented programming approach is used to implement the concept like polymorphism, data-hiding, etc. The main goal of oops is to reduce programming complexity and do several tasks simultaneously. The oops concepts are given below. • Class • Object • Inheritance • Polymorphism • Interfaces • Abstract class
  • 20.
    CLASS  Dart classesare 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> }
  • 21.
    OBJECT  An objectis 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. var objectName = new ClassName(<constructor_arguments>)
  • 22.
    INHERITANCE  Dart supportsinheritance, which is used to create new classes from an existing class. The class that to be extended is called parent /superclass, and the newly created class is called child/subclass.  Dart provides extends keyword to inherit the properties of parent class in child class. The syntax is given below. class child_class_name extends parent_class_name
  • 23.
    POLYMORPHISM  Polymorphism isan object-oriented programming concept where one thing has many forms. It can be two types - Runtime polymorphism and Compile time polymorphism.  For example - A function has the same name but with a different behavior or class.  Another example is the shape() class, and all the class inherited from the Rectangle, Triangle, and circle.
  • 24.
    INTERFACES  The interfaceis defined as a blueprint of the class. We can declare methods and variables inside the interface just like the class but in interface only abstract declaration of methods is provided.  We can only define the function signature but not its body.  Another class can implement the interface. It is basically used for data-hiding.
  • 25.
    ABSTRACT CLASS  Aclass that contains one or more abstract method is called an abstract class. We can declare the abstract class using the abstract keyword followed by class declaration. The syntax is given below. abstract class ClassName { //Body of abstract class }
  • 26.
    END OF THECHAPTER