Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
10 views

Chapter 2 Flutter Basics Lecture 1

abdisamed allaale
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

Chapter 2 Flutter Basics Lecture 1

abdisamed allaale
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 26

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

var name = 'Dart’;


 The final and const keyword are used to declare constants. They are
defined as below:
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.
void main() {
A simple List can be defined as below:
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:
void main() {
var mapping = {'id': 1,'name':'Dart’};
print(mapping);
}

 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

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(marks > 85) if (n<40){
{ print("The number is smaller tha
• If-else Statements
print("Excellent"); n 40")
• If else if Statement } };
• Switch Case Statement else if(marks>75) if(x > y){
{ print("x is greater than
switch (n) { print("Very Good"); y");
case 1: } } else {
print("Value is 1") else print("y is greater than
; { x");
break; print("Average"); };
default: }
print("Out of rang
e");
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. 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

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 add(int a,int b)


void main() {
{ int c;
add(3,4); 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_argum


ents>)
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

You might also like