0% found this document useful (0 votes)
16 views11 pages

App Development PPT 5

Uploaded by

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

App Development PPT 5

Uploaded by

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

Smartphone Application Development

Dart Programming Language

Md. Moshiur Rahman


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 Class Properties

Accessing Variable
Accessing Function
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.
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.
Inheritance
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.
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.
abstract class Shape {
double calculateArea(); // Abstract method
}

class Circle implements Shape {


double radius;

Circle(this.radius);

@override
double calculateArea() {
return 3.14 * radius * radius;
}
}

class Rectangle implements Shape {


double length;
double width;

Rectangle(this.length, this.width);

@override
double calculateArea() {
return length * width;
}
}

void main() {
Circle circle = Circle(5.0);
Rectangle rectangle = Rectangle(4.0, 6.0);

print('Area of circle: ${circle.calculateArea()}');


print('Area of rectangle: ${rectangle.calculateArea()}');
}

You might also like