0% found this document useful (0 votes)
4 views

Lesson3 - Advance Dart Programming.pptx

The document covers advanced Dart programming concepts, focusing on generics, mixins, inheritance, and exception handling. It explains how generics enable type-safe collections, the use of mixins for method reuse, and the implementation of interfaces. Additionally, it discusses debugging techniques and the importance of exception handling to ensure program stability.

Uploaded by

Loki Legends
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Lesson3 - Advance Dart Programming.pptx

The document covers advanced Dart programming concepts, focusing on generics, mixins, inheritance, and exception handling. It explains how generics enable type-safe collections, the use of mixins for method reuse, and the implementation of interfaces. Additionally, it discusses debugging techniques and the importance of exception handling to ensure program stability.

Uploaded by

Loki Legends
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 25

ADVANCED DART

PROGRAMMING

FLUTTER
• In Dart, by default collections are heterogeneous.
However, by the use of generics, we can make a
collection to hold homogeneous values. The use of
Generics makes the use of a single compulsory data
type to be held inside the collection. Such
GENERICS
collections are called type-safe collections. By the
use of generics, type safety is ensured in the Dart
language.
GENERIC CLASSES
• A generic class can handle multiple data types without being tied to a specific one.
GENERIC METHODS
• Generic methods allow you to define methods that operate on a generic type.
GENERIC LIST
• In Dart, a List is simply an ordered group of objects. A list is simply an implementation of an array.
GENERIC SET
• In Dart, a Set represents a collection of objects in which each object can exist only once.
GENERIC MAP
• In Dart, Map is a dynamic collection of the key, value pairs.
GENERIC QUEUE
• A queue is a collection that is used when the data is to be inserted in a FIFO (First in first out) manner. In Dart, a queue
can be manipulated at both ends, i.e. at the start as well as the end of the queue.
• Mixins are a way of reusing a class’s methods in
multiple class hierarchies.
MIXINS
MIXINS
• Mixins can be understood as abstract classes used for reusing the methods in various classes that have similar
functions/attribute.
• Mixins are a way to abstract and reuse a family of operations and state.
• It is similar to the reuse you get from extending a class, but is not multiple inheritances. There still only exists one
superclass.
• To use a mixin, use the “with” keyword followed by one or more mixin names.
• In Dart, the extends keyword is typically used to
alter the behavior of a class using Inheritance.
EXTENDS
EXTENDS
• The capability of a class to derive properties and characteristics from another class is called Inheritance. It is ability of
a program to create new class from an existing class.
• In simpler words, we can say that we use extends to create a subclass, and super to refer to the superclass. The class
whose properties are inherited by child class is called Parent Class. Parent class is also known as base class or super
class.
• The class that inherits properties from another class is called child class. Child class is also known as derived class, heir
class, or subclass.
• The extends keyword is the typical OOP class inheritance. If class Second extends class First all properties, variables,
methods implemented in class First are also available in Second class. Additionally, you can override methods.
• You use extend if you want to create a more specific version of a class. For instances if Apple extends from Fruit class, it
means all the properties, variables and functions defined in the Fruit class will be available in the Apple class.
In Dart, the implements keyword is used to enforce
that a class provides its own concrete implementation
for every method and property of an interface or
abstract class. IMPLEMENT
This is useful when you want multiple classes to follow
the same "contract" but provide different behaviors.
IMPLEMENT
• Interfaces define a set of methods available on an object. Dart does not have a syntax for declaring interfaces.
• Class declarations are themselves interfaces in Dart.
• An interface is something that enforces the deriving class to implement a set list of public fields and methods.
EXCEPTION HANDLING AND DEBUGGING TECHNIQUES.

An exception is an error that takes place inside the program. When an exception occurs inside a program the normal flow of the program
is disrupted and it terminates abnormally, displaying the error and exception stack as output. So, an exception must be taken care to
prevent the application from termination.

Debugging is the process of identifying and fixing errors in a program.


EXCEPTION HANDLING IN DART
• try: Defines a block of code to monitor for exceptions.
• catch: Handles exceptions when they occur.
• on: Handles a specific type of exception.
• finally: A block of code that always executes, regardless of exceptions.
THROW EXCEPTION
DEBUGGING TECHNIQUES
• Print statement - Use print() to output values or track the flow of the program. Simplest debugging technique.
• Using Dart Debugger - Use the built-in debugger in IDEs like VS Code or Android Studio.
• Set breakpoints to pause execution at specific lines.
• Inspect variable values at runtime.
DEBUGGING TECHNIQUES
• Stack Trace - Use the StackTrace object to get detailed information about the exception.
DEBUGGING TECHNIQUES
• Debugging with assert - The assert statement is used to test conditions during development.
DEBUGGING TECHNIQUES
• LoggingUse logging libraries like dart:developer or logger for advanced debugging.
• dart:developer - A built-in library in Dart for simple logging and debugging.
• logger - A popular package for advanced and customizable logging.

NOTES
• Exception handling ensures your program doesn't crash due to unexpected errors.
• Debugging techniques like print statements, stack traces, and breakpoints help you identify and fix issues.
• Proper handling of exceptions leads to robust and user-friendly applications.
THANK YOU ☺

RYAN FERMO

You might also like