You are on page 1of 10

Department of Artificial Intelligence and Machine Learning

In Association With IIC and IEEE Association


Workshop On “Development Of Android Application”

Dart Programming Language for


Flutter Mobile App Development
1. Simple example

2. Data Types – Numerics and Strings


Tipo de dato – Lista
A list is nothing more than a collection of objects that have something in
common (an array of numbers, etc).
Data Type – Map

They are widely known as data dictionaries. They are maps with a pair of values to which
a specific data type can be assigned.

Functions in Dart
void main() {} is an empty main function; void is used because it doesn't return anything, hence it's
empty. The print('hola'); is another function that takes an object (anything) → void (it doesn't return
anything).
We can create our own custom functions.
Classes in Dart
Classes are fundamental because if in Dart almost everything is an object, in Flutter almost
everything is a class.
A class is like a cookie cutter; if I want to make all cookies the same, I'll use that cutter, and
that cutter is a class. These classes are defined as follows.
The 'new' in Dart is optional; it is used to define a new instance of a class, but since version
2 of Dart, it's optional.
The difference between a method and a function is that the method is the one inside a
class, and a function is the one outside a class.
Remember that a constructor is a function.
Short Form of Defining Class Properties

When defining in a short form, we see that we don't need to use 'this' and use => when
creating a method with a single-line return. Additionally, we define the class in a concise
manner.

Named Constructors
Getters and Setters
If we add an underscore (_) to the properties of a class, it makes them private. This
means they will only work within their class, and outside the class, they cannot be
accessed. The setters (set), which are functions, are used to input data into private
properties.
Throw is used to throw an error message.
We calculate the area when requested, and with getters (get), we can use it outside
the class.

Abstract Classes
An abstract class allows me to compel other classes to implement the methods
and properties of the abstract class.
Extends

It is used to extend the properties and methods that a class has; it is used when
classes have common properties and methods.

Mixins

They are used to assign the methods or properties that I need from other
classes. For example, swimming, flying, and walking.
Futures

It is essential when performing asynchronous tasks, similar to JavaScript promises. A


future is an asynchronous task done in a thread independent of the main thread we are
executing, and when we get the return value, we can continue executing other parts of
our program.

You might also like