Mobile App Development 2 Flashcards
open-source general-purpose programming language. It is originally developed by Google and later approved as a standard by ECMA.
Dart
a new programming language
meant for the server as well as the browser
Dart
a transpiler that generates
JavaScript equivalent of a Dart Script
-dart2js
introduced by google, the dart sdk ship with its dart compiler?
Dart VM
what is dart
object-oriented language with C-style syntax which can optionally trans compile into JavaScript.
dart supports a varied range of programming aids like
- interfaces
- classes
- collections
- generics
- optional typing
Dart can be extensively used to
single-page application
what is single-page application
- enable navigation between different screens of the website without loading a different webpage in the browser
- Gmail
main() function
- predefined method
entry point of application
print()
predefined method that prints specified string or value
Dart Command-Line Options
- -c
- -h
- -p < path>
- –packages < path>
- –version
enables both assertions and type checks
-c
-h
displays help
–version
shows file version VM information
–packages < path >
path package resolution configuration file
-p < path>
where to find imported libraries
names given to elements in a program like variables,
functions
Identifiers
The rules for identifiers are
- not inslude special symbols except underscre and dollar sign
- unique
- identifers cannot be keywords
- identifiers are case-sensitive
- cannot contain spaces
object orientation
- software development paradigm that follows real-world modelling
- considers a program as a collection of objects that communicate with each other via mechanism called methods.
a real-time representation of any entity
Object
Grady Brooch,
every object must have three features
- state
- behavior
- identity
State
− described by the attributes of an object
Behavior
− describes how the object will act
identity
a unique value that distinguishes an object from a set of similar such
objects
class
- A class in terms of OOP is a blueprint for creating objects.
- A class encapsulates data for the object
method
facilitate communication between objects
Dart language supports the following types
- number
- string
- boolean
- list
- maps
are used to represent numeric literals.
numbers
two types off numbers
- integer
- double
- represent non-fractional values, i.e., numeric values without a decimal point.
- Integer literals are represented using the intkeyword
integer
- supports fractional numeric values i.e. values with decimal points.
- The Double data type in Dart represents a 64-bit (double-precision) floating-point number.
double
string
- represent a sequence of characters. For instance, if you were to store some data like name, address etc. the string data type should be used
- used to represent string literals. String values are embedded in either single or double quotes
sequence of UTF-16 code units
dart string
sequence of UTF-32 code units
Runes
boolean
data type represents Boolean values true and false
list and map
are used to represent a collection of objects
list
- ordered group of objects
- synonymous to the concept of an array in other programming languages
map
data type represents a set of values as key-value pairs
dart core
enables creation and manipulation of these collections through the predefined List and Map classes respectively.
dynamic
- type of a variable is not explicitly
- specified used as a type annotation explicitly
variable
- “a named space in the memory” that stores values.
- In other words, it acts a container for values in a program.
- Variable names are called identifiers.
keyword are used to declare constants
final and const
const
- compile time constant
- declared are implicitly final
List Properties
- first
- last
- isEmpty
- isNotEmpty
- length
- reversed
- single
first
returns first element in list
isEmpty
returns true if collection has no element
isNotEmpty
returns true if collection has at least one element
length
returns size of the list
reversed
returns an iterable object containing list values in reversed order
single
checks if list has only one element and returns it
Lists (Basic Operations)
- List.add()
- Update the index, List.replaceRange()
- following functions supported in dart:core library can be used to remove in list
List.add()
function depends in the specified value to the end of the List and returns a modified List object
Map
- simple key or value par
- dynamic collection
- shrink or grow at runtime
Maps can be declared in two ways
- using map literals
- using map constructors
Declaring a Map using Map Literals
- To declare a map using map literals, you need to enclose the key-value pairs within a pair of curly brackets “{ }”.
- Here is its syntax −
var identifier = { key1:value1, key2:value2 [,…..,key_n:value_n] }
Declaring a Map using a Map Constructor
- declar map
- initialize map
Map - Functions
1. addAll() - add key value pairs
2. clear() - remove all pairs from map
3. remove() - removes key adn associated value
4. forEach() - applies f to each key-value pair of mal
Map – Properties
1. Keys - Returns an iterable object representing keys
2. Values - Returns an iterable object representing values
3. Length - Returns the size of the Map
4. isEmpty - Returns true if the Map is an empty Map
5. isNotEmpty - Returns true if the Map is an empty Map
refers to the current instance of the class.
this