Lesson2 - Dart Object Oriented Programming.pptx
Lesson2 - Dart Object Oriented Programming.pptx
PROGRAMMING
FLUTTER
• Class is the blueprint of objects and class is the
collection of data members and data function means
which include these fields, getter and setter, and
CLASSES
constructor and functions.
DECLARING CLASS
• Class is the keyword used to initialize the class.
• class_name is the name of the class.
• The body of the class consists of fields, constructors, getter and setter methods, etc.
• Constructor: Initializes the object when an instance is created.
• The body of Constructor includes three things: Class Fields, Class Methods, and Constructors.
• Getters: Retrieves the value of a field.
• Setter: Updates the value of a field with validation.
• Function: Additional methods in the class that perform specific tasks.
• Objects are the instance of the class and they are
declared by using a new keyword followed by the OBJECTS
class name.
• Objects are the instance of the class and they are
declared by using a new keyword followed by the OBJECTS
class name.
OBJECTS
• new is the keyword use to declare the instance of the class
• object_name is the name of the object and its naming is similar to the variable name in dart.
• class_name is the name of the class whose instance variable is been created.
• arguments are the input which are needed to be pass if we are willing to call a constructor.
• In Dart, one class can inherit another class i.e dart
can create a new class from an existing class. We
make use of extend keyword to do so.
INHERITANCE AND
• Polymorphism: Ability of objects to take multiple POLYMORPHISM
forms.
CONCEPT OF INHERITANCE
• Parent Class: It is the class whose properties are inherited by the child class. It is also known as a base class or
superclass.
• Child Class: It is the class that inherits the properties of the other classes. It is also known as a deprived class or
subclass.
• Encapsulation is Restricting access to some
components while exposing others.
ENCAPSULATION AND
• Use _(underscore) to make a variable private.
• Null safety helps avoid null errors by requiring
NULL SAFETY
explicit nullability.
NULL SAFETY
• Null Safety in simple words means a variable cannot contain a ‘null’ value unless you initialized with null to that variable. With
null safety, all the runtime null-dereference errors will now be shown in compile time.
Non-Nullable Types
• When we use null safety, all the types are non-nullable by default. For example, when we declare a variable of type int, the
variable will contain some integer value.
Example:
int marks;
marks = null;
Nullable Types
• To specify if the variable can be null, then you can use the nullable type ? Operator.
Late Keyword
• As we knew that all variables are non-null by default, we can use either the ? operator or the late keyword.
THANK YOU ☺
RYAN FERMO