0% found this document useful (0 votes)
4 views7 pages

Oop 2

The document outlines a Flutter Development Diploma course focused on Object-Oriented Programming (OOP) concepts such as inheritance, abstraction, polymorphism, optional parameters, and null safety in Dart. It explains key features like how inheritance allows a child class to inherit properties from a parent class, and how null safety helps prevent errors from null variables. Additionally, it covers method overriding and the use of optional parameters in function definitions.

Uploaded by

qwer353666
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)
4 views7 pages

Oop 2

The document outlines a Flutter Development Diploma course focused on Object-Oriented Programming (OOP) concepts such as inheritance, abstraction, polymorphism, optional parameters, and null safety in Dart. It explains key features like how inheritance allows a child class to inherit properties from a parent class, and how null safety helps prevent errors from null variables. Additionally, it covers method overriding and the use of optional parameters in function definitions.

Uploaded by

qwer353666
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/ 7

Flutter Development

Diploma
Become a Flutter Developer with just one course

Session 2 (OOP)
• OOP pt2 & Null Safety
1. Inheritance
2. Abstraction
3. Polymorphism
4. Optional Parameters
5. Null Safety
Flutter Diploma
Become a Flutter Developer with just one course

01 Inheritance

• Inheritance is a feature or a process in which, new class is


created from the existing class.
• The new class created is called “child class”, “derived
class” or “subclass”.
• The existing class is called “parent class”, “base class” or
“superclass”.
• Child class inherit all properties and methods of the parent
class.
• Dart doesn’t support multiple inheritance.

https://www.javatpoint.com/dart-inheritance
Flutter Diploma
Become a Flutter Developer with just one course

02 Abstraction

• An abstract class mostly used to offer a base for the


subclass to extends and implement the abstract method.
• Abstract classes cannot be instantiated.
• An abstract method is a method without a body and can’t
be declared within in abstract class.
• Every subclass must override the parent class method by
provides its own implementation.
• We can force the subclass to provide implementation to that
method, so that is the benefit to make method abstract.
• An abstract method is a method without a body and can’t
be declared within in abstract class.

https://www.javatpoint.com/dart-abstract-classes

Method Overriding
• When we declare the same method in the subclass,
which is previously defined in the superclass is known as
the method overriding.
• Method overriding is used to provide the specific
implementation of a method which is already provided
by its superclass.
• Method overriding is used for runtime polymorphism.

https://www.javatpoint.com/dart-method-overriding
Flutter Diploma
Become a Flutter Developer with just one course

03 Polymorphism

• Polymorphism in is a concept by which we can perform


a single action in different ways.
• We can achieve polymorphism in dart by method overriding.

https://dart-tutorial.com/object-oriented-
programming/polymorphism-in-dart
Flutter Diploma
Become a Flutter Developer with just one course
Flutter Diploma
Become a Flutter Developer with just one course

04 Optional Parameters
➢ Optional Positional Parameters:
• Define by put your nullable
parameters between [].
• All parameters inside [] are optional, which means
they must be nullable.
• When calling a function, you specify each
argument without their name.
• You can omit any arguments.
• Order of argument does matter.

➢ Optional named parameters:


• Define by putting your parameters between curly
brackets {}.
• Named parameters are optional unless they’re
explicitly marked as required.
• When calling a function, you specify argument
with their name using paramName: value.
• You can omit non-required field at the call site.
• Order of argument doesn't matter.
Flutter Diploma
Become a Flutter Developer with just one course

05 Null Safety

• Null safety prevents errors that result from unintentional


access of variables set to null.
• Null safety changes potential runtime errors into edit-
time analysis errors, by flagging when any non-nullable
variable hasn’t been initialized with a non-null value or
is being assigned a null.
• By default, Dart variables aren’t nullable unless you
explicitly specify that they can be null.
• To indicate that a variable might have the value null, just
add ? to its type declaration.

• Use the null assertion operator ! to make Dart treat a


nullable expression as non-nullable if you’re certain it
isn’t null.
• If a non-nullable instance variable can't be initialized
with a default value, set it with a constructor.
• The keyword late can be used to mark variables that
will be initialized later.
• The null-aware operator is ??, which returns the
expression on its left unless that expression’s value is
null. In which case it’s null it returns the expression on its
right.

https://dart.dev/null-safety/understanding-null-safety
https://dart.dev/codelabs/null-safety

You might also like