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

Lecture02-II - Introduction To Dart

This document provides an introduction to the Dart programming language. It discusses what Dart is, its history and development by Google, its uses for mobile app development with Flutter and web development, and its key features. These features include being optimized for user interfaces, having a familiar syntax, productive development with hot reloading, running fast on multiple platforms, and facilitating smooth animations. The document also provides code examples and explanations of core Dart concepts like data types, collections like lists and maps, control flow statements, functions, classes and constructors.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
87 views

Lecture02-II - Introduction To Dart

This document provides an introduction to the Dart programming language. It discusses what Dart is, its history and development by Google, its uses for mobile app development with Flutter and web development, and its key features. These features include being optimized for user interfaces, having a familiar syntax, productive development with hot reloading, running fast on multiple platforms, and facilitating smooth animations. The document also provides code examples and explanations of core Dart concepts like data types, collections like lists and maps, control flow statements, functions, classes and constructors.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 36

Current Trends in Software Engineering

Lesson 3: Introduction to Dart


Content

 What is Dart?
 Dart History
 Dart Features
 Flutter & Dart
 Start Coding with Dart...
What is Dart?
 Dart is a client-optimized programming language for apps on multiple
platforms.

 Dart is an open-source general-purpose programming language.

 It is developed by Google and is used to build mobile, desktop, backend and


web applications.

 Dart is an object-oriented, Strongly Typed, garbage-collected language


Dart History
 Dart was unveiled at the GOTO conference in Aarhus, Denmark, October
10–12, 2011

 The project was founded by Lars Bak and Kasper Lund

 Dart 1.0 was released on November 14th, 2013.

 Recently release Dart 2.6 is accompanied with a new extension


dart2native.
Dart Usage

 Mobile app development using Flutter

 Web development (using Dart2JS)

 Server side (using various libraries and frameworks)


Dart features
 Optimized for UI
Develop with a programming
language specialized around the
needs of user interface creation

 A programming language that is easy


to learn, with a familiar syntax
Dart features Cont…

 Productive development
• Make changes iteratively: use hot reload to see the result instantly in your running
app
• Write code using a flexible type system with
rich static analysis and
powerful, configurable tooling

• Do profiling, logging, and debugging with


your code editor of choice
Dart features Cont…

 Fast on all platforms


Compile to ARM & x64 machine code for mobile, desktop, and backend.
Or compile to JavaScript for the web

 Dart can also be JIT (Just In Time) compiled for exceptionally fast
development cycles

 Dart makes it easier to create smooth animations and transitions that run
at 60fps.

 Dart can do object allocation and garbage collection without locks.


Flutter and Dart
Dart Installation

Dart SDK
Use the community-supported Dart SDK installer for Windows

DartPad
It is an online editor at https://dartpad.dartlang.org
Dart SDK
Hello World
Data Types
Dart is an optionally typed language

• Numbers
Int and double
• Strings
String is used to represent string literals.
• Booleans
Uses the bool keyword to represent a Boolean value.
• Lists
Ordered group of objects and it is synonymous to the concept of an array in other
programming languages. List
• Maps
set of values as key-value pairs. Map
• Dynamic
If the type of a variable is not explicitly specified, the variable’s type is dynamic.
Dart input output handling
Using Labels to Control the Flow

• A label is simply an identifier followed by a colon (:) that is applied to a


statement or a block of code.

• A label can be used with break and continue to control the flow more
precisely.

• Line breaks are not allowed between the ‘continue’ or ‘break’ statement and
its label name. Also, there should not be any other statement in between a
label name and an associated loop.
Control flow statements
Collections - List
• Dart represents arrays in the form of List objects. A List is simply an ordered group of
objects.
• The dart:core library provides the List class

List

Fixed Length List


Growable List
var list_name = new List(initial_size)
var list_name = [val1,val2,val3]
lst_name[index] = value;
creates a list containing the specified values
OR
var list_name = new List()
creates a list of size zero
Collections - List

Fixed Length List


Collections - List
Growable List
Collections - Map

• The Map object is a simple key/value pair. Keys and values in a map may be
of any type. A Map is a dynamic collection.

• Maps can be declared in two ways −


Using Map Literals
var identifier = { key1:value1, key2:value2 [,…..,key_n:value_n] }

Using a Map constructor


var identifier = new Map()
map_name[key] = value
Collections - Map
Collections - Queue
Imports
Functions
Lambda Functions
Classes
Dart supports all the features for Object-oriented programing paradigm like Classes,
Inheritance, Interfaces, Polymorphism, etc.

Create
Class Object
example
Classes
Constructors

• A constructor is an instance method that is invoked when an object is


created from the class.
• This is a good place to initialize instance variables.
Named constructors

Dart provides multiple constructors on a class. Apart from default constructors,


other constructors must have a name. While creating an object from a class, we
need to use the name named constructor.
Dart Access Specifiers

• Dart doesn't provide Access specifiers keywords like private, public and
protected.

• can use _ (underscore) at the start of the name to make a data member of a
class becomes private.

• So, a data member is either public (if not preceded by _) or private (if
preceded by _)
Dart Access Specifiers
a.dart

other.dart
Dart Access Specifiers
a.dart

other.dart
Class Inheritance- interface
 Dart has no interface keyword.
Class Inheritance – Abstract class
Mixins
• A Mixin is a class that contains methods for use by other classes without
having to be the parent class of those other classes.

• mixins are normal classes from which we can borrow methods(or


variables) from without extending the class.
Thank You

You might also like