Busy Developer's Guide to Dart Ted Neward Neward & Associates - - PowerPoint PPT Presentation

busy developer s guide to dart
SMART_READER_LITE
LIVE PREVIEW

Busy Developer's Guide to Dart Ted Neward Neward & Associates - - PowerPoint PPT Presentation

Busy Developer's Guide to Dart Ted Neward Neward & Associates http://www.tedneward.com | ted@tedneward.com Dart Overview In a nutshell... Dart Overview Dart "Dart is a class-based, single-inheritance, pure object-oriented


slide-1
SLIDE 1

Busy Developer's Guide to Dart

Ted Neward Neward & Associates http://www.tedneward.com | ted@tedneward.com

slide-2
SLIDE 2

Dart Overview

In a nutshell...

slide-3
SLIDE 3

Dart Overview

Dart

"Dart is a class-based, single-inheritance, pure object-oriented programming language. Dart is optionally typed and supports reified generics. The runtime type of every object is represented as an instance of class Type which can be

  • btained by calling the getter runtimeType declared in class

Object, the root of the Dart class hierarchy. "Dart programs may be statically checked. The static checker will report some violations of the type rules, but such violations do not abort compilation or preclude execution. "Dart programs may be executed in one of two modes: production mode or checked mode. In production mode, static type annotations have absolutely no effect on execution with the exception of reflection and structural type tests. In checked mode, assignments are dynamically checked, and certain violations of the type system raise exceptions at run time."

slide-4
SLIDE 4

Dart Overview

Dart

– developed at Google – developed because "Google cares about the Web"

specifically built for Google's own use

– ECMA standard (ECMA-408)

4th Edition (December 2015)

– targets multiple contexts

  • command-line applications

these run in the DartVM

  • front-end web development

these will typically transpile to Javascript

  • iOS/Android applications

makes use of Flutter (https://flutter.io)

slide-5
SLIDE 5

Objectives

What are we going to do today?

– examine the Dart ecosystem – learn (a bit) about the Dart language

slide-6
SLIDE 6

Getting Started

From Zero to Hello World

slide-7
SLIDE 7

Getting Started

Hello, Dart

– easiest way to play with Dart is with DartPad

https://dartpad.dartlang.org/33706e19df021e52d98c

– ... but that's not what we're after!

slide-8
SLIDE 8

Getting Started

Requirements to install Dart

– Windows, Mac or Linux OS

that's pretty much it

slide-9
SLIDE 9

Getting Started

Installing on Windows

– Chocolatey

choco install dart-sdk -version {version} choco install dartium -version {version}

– MSI installer (community-sponsored)

slide-10
SLIDE 10

Getting Started

Installing on Mac

– Homebrew

brew tap dart-lang/dart brew install dart --with-content-shell --with-dartium

slide-11
SLIDE 11

Getting Started

Installing on Linux

$ sudo apt-get update $ sudo apt-get install apt-transport-https # Get the Google Linux package signing key. $ sudo sh -c 'curl https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -' # Set up the location of the stable repository. $ sudo sh -c 'curl https://storage.googleapis.com/download.dartlang.org/linux/debian/dart_st able.list > /etc/apt/sources.list.d/dart_stable.list' $ sudo apt-get update

Source: https://www.dartlang.org/install/linux

slide-12
SLIDE 12

Getting Started

Installing manually

– Download zip file

https://www.dartlang.org/install/archive

– Unzip manually, set PATHs, etc

slide-13
SLIDE 13

Getting Started

Hello, Dart

// Define a function. printNumber(num aNumber) { print('The number is $aNumber.'); // Print to the console. } // This is where the app starts executing. main() { print("Hello, Dart"); // Print to the console. var number = 42; // Declare and initialize a variable. printNumber(number); // Call a function. } $ dart hello.dart Hello, Dart The number is 42.

slide-14
SLIDE 14

Getting Started

Hello, Dart

– execution begins in main() – print() writes to the console

which is always present, context-dependent location

slide-15
SLIDE 15

Modes

Dart has two modes: production and checked

– Checked is "developer mode"

  • verify static types
  • execute assert() statements

– Production is... well, duh

  • ignores type declarations
  • ignores assert() statements
  • optimized for speed
slide-16
SLIDE 16

Basic Syntax

slide-17
SLIDE 17

Basic Syntax

Source code

– Dart (like most languages) is a text-based language – Source code is in the common subset of Unicode supported by most languages

  • effectively, ASCII
  • note that this is not specifically described anywhere; could

expand to full Unicode at some point

– Comments are either // or /* */ -style comments

  • // -- to end-of-line
  • /* */ -- multiline comment using (nestable) open/close pairs
  • /// -- documentation comment to end-of-line
  • /** */ -- multiline documentation comment using open/close

pairs

slide-18
SLIDE 18

Basic Syntax

Identifiers

– C-style Identifiers

starts with letter or _, followed by letters/numbers/_

– reserved words cannot be used as Identifiers

abstract as assert async async* await break case catch class const continue default deferred do dynamic else enum export external extends factory false final finally for get if implements import in is library new null operator part rethrow return set static super switch sync* this throw true try typedef var void while with yield yield*

slide-19
SLIDE 19

Basic Syntax

Format

– made up of statements and expressions

  • expressions yield values
  • statements do not

– statements/expressions must be terminated by semicolon

in the spirit of C, C++, Java, C#, ...

slide-20
SLIDE 20

Primitive Types

The atoms of the type system

slide-21
SLIDE 21

Primitive Types

Important concepts

– Everything you can place in a variable is an object – Every object is an instance of a class

numbers, functions, and null are objects

– All objects inherit from the Object class – Dart supports top-level variables (globals)

slide-22
SLIDE 22

Primitive Types

Variables

– declared using either "var name" or "{type} name"

in the spirit of C, C++, Java, C#, ...

– mutable by default; use "final" or "const" to make immutable

  • final means only-assigned-once
  • const must be a compile-time constant

– uninitialized variables initialize to null

slide-23
SLIDE 23

Primitive Types

Numbers ("num")

– num type supports most expected operations

  • "+", "-", "*", "/", "%"
  • abs(), floor(), ceil(), ...

– "int" (signed, -2^53 to 2^53) is subtype of "num"

  • supports bitwise shift ("<<" ">>", "&", "|") operators

– "double" (64-bit IEEE 754 floating-point) is also subtype of "num"

slide-24
SLIDE 24

Primitive Types

Strings ("string")

– sequence of UTF-16 code units – literals denoted by single-tick or double-tick pairs

  • backslash can denote special characters ("\n", "\t", etc)
  • backslash-escaping turned off by "raw" strings ("r"-prefixed

string)

– strings also support $-denoted string interpolation – strings concatenate using "+" or simply being adjacent to

  • ne another

– strings support "multi-line" strings using triple-quoted marks

slide-25
SLIDE 25

Types

Primitive Types

var x = 1; var y = 1.1; var exponents = 1.42e5; var one = int.parse('1'); assert(one == 1); var oneStr = 1.toString(); assert(1 == (int.parse(1.toString()))); var s1 = 'Hello ' 'world' " from Dart"; print(s1); var s2 = ''' Multi- line strings '''; print (s2); var s3 = 'string interpolation'; var s4 = 'Dart has $s3, which is handy'; // Dart has string interpolation, which is handy

slide-26
SLIDE 26

Primitive Types

Booleans ("bool")

– only two possible values, "true" and "false" – in boolean expressions, only "true" is true

no ECMAScript-like "truthy"/"falsy" implicit conversions; generates an exception in checked mode

slide-27
SLIDE 27

Types

Type-checking can avoid common errors

var name ='Bob'; if (name) { print('JavaScript says you have a name!'); // dart --checked will throw an exception, because // 'name' is not a boolean type } if (1) { print('JavaScript prints this line because it thinks 1 is true.'); } else { print('Dart in production mode prints this line.'); // However, in checked mode, if (1) throws an exception. }

slide-28
SLIDE 28

Primitive Types

Lists (arrays)

– denoted using square-brackets ("[]") – literals use commas to separate values

"const" before the literal makes it a compile-time constant list

– square-brackets used to access individual elements by position – zero-based indexing – .length returns the length of the list – lists are mutable by default

it is possible to create immutable lists

slide-29
SLIDE 29

Primitive Types

Maps (dictionaries)

– denoted using curly-brackets ("{}") – literals use commas to separate colon-associated pairs of values

"const" before the literal makes it a compile-time constant map

– square-brackets used to access individual elements by key

missing keys yield null

– .length returns the length of the list of pairs – maps are mutable by default

slide-30
SLIDE 30

Primitive Types

Runes (UTF-32 code points)

– referenced using "\uXXXX" syntax (where XXXX is 4-digit hex) – for larger than 4-digit hex, surround the value with {}

slide-31
SLIDE 31

Primitive Types

Symbols

– represents an operator or identifier declared in a Dart program

invaluable for APIs that refer to identifiers by name; minification changes identifier names but not identifier symbols

– symbol literals use "#"-prefixed literal name – compile-time constants – most often used in conjunction with dart:mirrors- reflection library

slide-32
SLIDE 32

Primitive Types

Functions

– functions are objects of type Function – this allows functions to be passed, stored, etc

enables a certain subset of functional programming style

slide-33
SLIDE 33

Primitive Types

Enumerations (enums)

– use "enum" keyword; integer-backing – access the integer backing value using ".index" – get a full list of the enum values using static "values" constant – when used in switch statements, compiler checks for full- range evaluation

slide-34
SLIDE 34

Primitive Types

dynamic

– "placeholder" type designed to allow for optional typing

essentially compiler will do no type-checking around a dynamic-declaration

slide-35
SLIDE 35

Control Flow

Ifs, ands, whiles and fors

slide-36
SLIDE 36

Control Flow

If/else

– standard C-style "if" construct

else is optional, else if chains tests, etc

– must be boolean test expression

slide-37
SLIDE 37

Control Flow

If

if (isRaining()) { print("Welcome to Seattle"); } else if (isSnowing()) { print("Welcome to... uh... the US"); } else { print("Welcome to Las Vegas"); }

slide-38
SLIDE 38

Control Flow

While and do/while

– standard C-style "loop until false" constructs – must be boolean test expression

slide-39
SLIDE 39

Control Flow

While and do/while

while (isRaining()) { print("Stay indoors"); } do { print("Writing code while I stay indoors"); } while(isRaining());

slide-40
SLIDE 40

Control Flow

For (three-expression style)

– pretty much everything the C-style for does

slide-41
SLIDE 41

Control Flow

For-in (iteration style)

– any Iterable object supports for-in – any change to the collection breaks the iteration – Iterable objects also support forEach() (preferred)

slide-42
SLIDE 42

Control Flow

Switch/case

– standard C-style "switch" block – each non-empty "case" must terminate with "break"

  • empty case statements fall through
  • alternatively, use "continue {label}" to force fall-through

– case matches must be compile-time constants

slide-43
SLIDE 43

Control Flow

Assert

– accept boolean condition, then generate exception if false – only operate as intended in checked mode

in production mode, they turn into a no-op

slide-44
SLIDE 44

Control Flow

Try/catch/throw

– "throw new {object}" immediately begins walk up call stack

any arbitrary object may be thrown

– "try" { body } establishes range of guarded code – "on {type} { body }" executes body on {type} exceptions – "catch(ex) { body }" is the catch-all handler – "finally { body }" always executes

slide-45
SLIDE 45

Operators

Doing 'x' to 'a' and 'b'

slide-46
SLIDE 46

Operators

Dart supports full range of operators

– mathematical ( ++ -- + - * / % ~/ )

including math-assignment ( = += -= *= /= %= ~/= ) ~/ ~/= are "divide with integer result"

– bitwise ( << >> & ^ | )

including bitwise-assign ( <<= >>= ^= |= &= )

– relational ( == != && || <= >= < > )

including conditional ( t : a ? b )

– type-test ( as is is! ) – object-related ( () [] . ?. .. ) – NOTE: operator implementation resolution use the left- hand operand

ex: aVector + aPoint will use aVector's implementation of +

slide-47
SLIDE 47

Operators

Equality tests

– == != do an equality comparison

meaning, compare the contents

– == returns null if lhs or rhs is null – to do an identity comparison, use the identical() function

slide-48
SLIDE 48

Operators

Null-safe operators

– ?? is the null-test operator

a ?? b returns a if a != null, else b

– ?. is the null-safe resolution operator

a?.b yields b returns b if a != null, else null

slide-49
SLIDE 49

Functions

Capturing logic

slide-50
SLIDE 50

Functions

Functions: named blocks of code

– C-style syntactic approach

return-type function-name(param-type param-name, ...) { body }

– types are encouraged, but not mandatory

function-name(param-name, ...) { body }

– body can be elided if it is a simple expression-return

function-name(param-name, ...) => expression

slide-51
SLIDE 51

Functions

Simple functions

void printNumber(num number, num times) { print('The number you passed is $number.'); } void printAnotherNumber(number) => print('Here is $number.'); void main() { var printIt = (number) => print('Yet again, $number.'); printNumber(27); printAnotherNumber(27); printIt(27); }

slide-52
SLIDE 52

Functions

Parameters come in two flavors: required and

  • ptional

– required come first – optional parameters can be either positional or named (not both)

  • named defined using {}-denoted enclosing parameter list
  • positional defined using []-denoted parameter list
  • optional named parameters invoked using name: value lists
slide-53
SLIDE 53

Functions

Optional parameters can have default values attached

– use "=" syntax after param-name in list – without default value, optional parameters (if not passed) are null

slide-54
SLIDE 54

Functions

Optional named and positional parameters

void doSomething({bool printIt: false, bool logIt: true}) { if (printIt) { print("We're printing something"); } if (logIt) { print("We're logging something"); } } void logIt(String msg, [String language: 'English']) { print("We're logging $msg in $language."); } void main() { doSomething(printIt: true, logIt: false); logIt("Hello, world!"); }

slide-55
SLIDE 55

Functions

Functions are first-class objects

– passed as parameters, stored as variables, etc

all functions are of type "function"

– "ordinary" objects can also be made callable

implement a call() function in the class

– Function types can be expressed using "typedef"

typedef int Compare(Object a, Object b); "Compare" is now a function type that can be used/compared/etc

slide-56
SLIDE 56

Functions

First-class functions

bool shortName(string name) => name.length < 10; bool printName(string name) { print("$name is easy to vote for."); } void main(List<string> args) { List<string> candidates = [ "Barack Obama", "Joe Biden", "John McCain", "Sarah Palin", "Mickey Mouse", "Goofy" ]; var shortList = candidates.where(shortName); shortList.forEach(printName); }

slide-57
SLIDE 57

Functions

Functions can be lexically nested

– nested functions are no different than non-nested functions – except that they cannot be seen from outside lexical scope

in other words, just as with any other variable

– aids in implementation-hiding

slide-58
SLIDE 58

Functions

Anonymous functions (lambdas, closures, etc)

– uses "fat arrow" syntax

(param-list) => { statements }; (param-list) => statement;

– types may be specified to parameter list (optional) – access to surrounding lexical scope – closure capture is by-value, not by-reference

value of the variable enclosed is captured at time of closure creation

slide-59
SLIDE 59

Functions

Closures

// "function" is the return type, not a keyword! function makeAdder(num addBy) { // Not seen outside of makeAdder() adder(num i) { return addBy + i; } return adder; } void main() { var addBy2 = makeAdder(2); assert(add2(3) == 5); var addBy4 = makeAdder(4); assert(add4(3) == 7); // Closures capture by-value not by-reference var callbacks = []; for (var i = 0; i < 2; i++) { callbacks.add(() => print(i)); } callbacks.forEach((c) => c()); // prints 0, 1; in JavaScript, this would be 2, 2 }

slide-60
SLIDE 60

Classes

Defining types in Dart

slide-61
SLIDE 61

Classes

Classes define types

– all objects are instances of a class – class keyword begins definition – classes have members

  • variables
  • constructors
  • methods (including getters/setters)
  • operators

– members can also be static

  • variables
  • methods
slide-62
SLIDE 62

Classes

Class syntax

– access is either public or private

  • denoted by presence/absence of leading _
  • "foo" would be public
  • "_foo" would be private

– "this" keyword refers to instance – "." is access operator to obtain members

slide-63
SLIDE 63

Classes

Cascade operator ("..")

– used to reference a previous object – essentially another way of doing "fluent chaining"

typically useful for setters or non-return-capturing methods

– cascade as many times as desired/necessary

slide-64
SLIDE 64

Classes

Instance variables

– "{type} {identifier}" defines instance variable – implicitly defines getter and setter

setter only for mutable (non-final, non-const) variables

– initialized to null if not explicitly initialized

slide-65
SLIDE 65

Classes

Simple class declaration/use

class Person { // These are all public String lastName = "(None)"; String firstName; // initially null // These are private (_-prefixed) num _age = 0; Person(this.firstName, this.lastName); Person.singular(String firstName) { this.firstName = firstName; } } void speakers() { Person speaker = new Person("Ted", "Neward"); Person theDude = new Person.singular("The Dude"); speaker.firstName = "The Dude"; }

slide-66
SLIDE 66

Classes

Constructors

– blocks of code to initialize objects before use – no return type, uses same name as class – if no constructor is declared, default (no-arg) constructor is synthesized – "simple constructors" are constructors that just assign params to member variables

  • use "this.{member}" in parameter list to match params to

members

  • these assignments happen before the body of the

constructor runs

slide-67
SLIDE 67

Classes

Chaining constructors

class Point { num x; num y; Point(this.x, this.y); // Chained constructor Point.alongXAxis(num x) : this(x, 0); }

slide-68
SLIDE 68

Classes

Named constructors

– "named constructors" provide additional constructors or clarity

"{Classname}.{identifier}(param-list) { body }"

– used exactly the same way from client code – syntactically similar (identical) to static methods in other languages

slide-69
SLIDE 69

Classes

Initializer lists

– defined between constructor parameter list and actual body – serves to allow easy member initialization from parameters – initializer lists execute prior to constructor body

very handy for initializing final-declared members

slide-70
SLIDE 70

Classes

Factories are constructors of a sort

– they return instances of the type

but not always new instances

– always invoked using "new"

in other words, client never knows the difference

slide-71
SLIDE 71

Classes

Factories

class OverdoneDemo { final String name; static final OverdoneDemo _instance = new OverdoneDemo._internal("Singleton!"); OverdoneDemo._internal(this.name); factory OverdoneDemo() { return _instance; } } void overdone() { var od = new OverdoneDemo(); print(od.name); print(new OverdoneDemo().name); print(new OverdoneDemo().name); }

slide-72
SLIDE 72

Classes

Methods

– functions defined on the class – can be either instance or static

  • instance have lexical access to "this" by default
  • static have lexical access to static members by default

– can be abstract by leaving out method body (terminate with semicolon)

non-abstract classes can have abstract methods

slide-73
SLIDE 73

Classes

Properties ("getters and setters")

– each instance variable already has an implicit getter/setter – use "get"/"set" to implement additional Properties

typically these will use "shortcut" function/method syntax

slide-74
SLIDE 74

Classes

Properties

class Rectangle { num left; num top; num width; num height; Rectangle(this.left, this.top, this.width, this.height); num get right => left + width; set right(num value) => left = value - width; num get bottom => top + bottom; set bottom(num value) => top = value - height; }

slide-75
SLIDE 75

Classes

Operator overriding

– finite/limited set of operators available for overriding

< > <= >= + - / ~/ * % | ^ & << >> [] []= ~ ==

– define a non-static method using "operator (op)" as the name – Dart leaves it up to the developer to make common-sense decisions here

slide-76
SLIDE 76

Classes

Operators

class Vector { final int x; final int y; const Vector(this.x, this.y); Vector operator +(Vector v) { return new Vector(x + v.x, y + v.y); } Vector operator -(Vector v) { return new Vector(x - v.x, y - v.y); } } main() { final v = new Vector(2, 3); final w = new Vector(2, 3); assert((v+w).x == 4 && (v+w).y == 6); }

slide-77
SLIDE 77

Inheritance

Implementation reuse via inheritance

slide-78
SLIDE 78

Inheritance

Implementation inheritance

– single base – use "extends" to denote superclass – use "super" to refere to superclass – instance methods, getters, setters are overridable

prefer use of @override to allow compiler verification

– note Object.noSuchMethod()

this is invoked whenever a member is not found during invocation

slide-79
SLIDE 79

Inheritance

Interfaces

class TV { void turnOn() { _illuminateDisplay(); _activateIRSensor(); } } class SmartTV extends TV { @override void turnOn() { super.turnOn(); _bootNetworkInterface(); _initializeMemory(); _upgradeApps(); } }

slide-80
SLIDE 80

Inheritance

Interfaces

– every class implicitly defines its own interface – classes can "implements" a class and get the interface

but no implementation

– all members are defined by the interface

but not always visible to subclasses

slide-81
SLIDE 81

Inheritance

Interfaces

class ThoughtLeader { String _name; // part of the interface, but not always visible ThoughtLeader(this._name); // not part of the interface String greet(who) => "Hello, $who. I am $_name, a Thought Leader."; } class Imposter implements ThoughtLeader { final _name = ""; // required -- part of the interface String greet(who) => "Hello, $who. Don't you know who I am?"; }

slide-82
SLIDE 82

Inheritance

Mixins

– permit code reuse from classes without establishing IS-A relationship – to implement a mixin, create a class that...

  • extends Object
  • declares no constructors
  • has no class to super
slide-83
SLIDE 83

Inheritance

Mixins

abstract class Musical { bool canPlayPiano = false; bool canCompose = false; bool canConduct = false; void entertainMe() { if (canPlayPiano) { print("playig piano"); } else if (canConduct) { print("waving hands"); } else { print("humming"); } } } class Musician extends Object with Musical { } class Maestro extends Person with Musical, Aggressive, Demented { Maestro(String maestroName) { super.singular(maestroName); canConduct = true; } }

slide-84
SLIDE 84

Generics

Your favorite reusable quote here

slide-85
SLIDE 85

Generics

Dart supports parametric polymorphism

– aka "templates" or "generics" – type-replacement of type-parameter from defintion-time

restrict type parameter via "extends" clause in declaration

– angle-bracketed notation (a la Java, C++, C#, etc) – reified types

type-parameter accessible at runtime (even in production mode)

slide-86
SLIDE 86

Generics

Collection literals can be type-parameterized

– place the type-parameter in angle-brackets before the actual literal – this will define the types explicitly in otherwise-implicit scenarios

slide-87
SLIDE 87

Generics

Collection literals

void main() { var bowlingLeague = <String>["Walter", "Donny", "The Dude"]; var bowlingScores = <String, int>{ "Walter":'198', "Donny":'196', "The Dude":'217' }; var names = new List<String>(); // same as bowlingLeague var scores = new Map<String,int>(); // bowlingScores var uniqueNames = new Set<String>.from(bowlingLeage); print(uniqueNames is Set<String>); // true }

slide-88
SLIDE 88

Generics

Generic functions

– methods/functions can have type parameters as well – place angle-bracketed type-parameter list immediately after name

slide-89
SLIDE 89

Asynchrony

Walking and chewing gum at the same time (in Dart)

slide-90
SLIDE 90

Asynchrony

Async/await

– Dart supports asychrony through async/await keywords

and Future and Stream objects

– for-in can be used with Stream objects

prefix the "for" with "await"

slide-91
SLIDE 91

Metadata

Providing data about types in Dart

slide-92
SLIDE 92

Metadata

Dart supports metadata through annotations

– @-prefixed class instances – accessible via reflection – custom annotation types possible

simple class

slide-93
SLIDE 93

Libraries

Using/creating reusable bodies of code in Dart

slide-94
SLIDE 94

Libraries

Libraries are APIs and a unit of privacy

– every Dart app is a library – libraries can be distributed using "pub" (package manager)

slide-95
SLIDE 95

Libraries

Import

– import specifies how a namespace from one library is used in the scope of another library

"import 'dart:html'"

– argument to import is a URI specifying the library

  • "dart:" is a special scheme for Dart built-in libraries
  • "package:" scheme refers to package manager-managed

libraries

  • otherwise, a file system path

– imports can define a prefix for all names in the library

"import 'package:lib2/lib2.dart' as lib2;"

– selectively import symbols using "show"

"import 'package:foo/hello.dart' show foo;"

– selectively exclude symbols using "hide"

"import 'package:foo/hello.dart' hide foo;"

slide-96
SLIDE 96

Libraries

Deferred import

– libraries can be lazily loaded (deferred) until required – import using "deferred as"

"import 'package:deferred/hello.dart' deferred as hello;"

– then load-on-demand using loadLibrary()

this returns a Future

slide-97
SLIDE 97

Libraries

Creating libraries

– libraries consist of multiple things

  • code units
  • manifest (pubspec.yaml)

– Dart has strong recommendations about file organization

"strong" meaning "some are requirements"

slide-98
SLIDE 98

Libraries

Library organization

– root directory contains pubspec.yaml (manifest) – root directory contains "lib"

  • by convention, exported code lives in "lib"
  • by convention, implementation code lives in "lib/src"

– root will often have other directories

  • example
  • test
  • tool (library-private-use tools)
  • bin (public-use tools)
slide-99
SLIDE 99

Libraries

pubspec.yaml

– text file (YAML format) describing the library – name: (required) – version: (required for pub.dartlang.org) – description: (required for pub.dartlang.org) – author or authors: (optional) – homepage: (optional) – documentation: (optional)

slide-100
SLIDE 100

Libraries

pubspec.yaml

– dependencies: – dev_dependencies: – dependency_overrides: used to override dependencies – environment: configure version of Dart SDK used – executables: puts package executables on the path – transformers: configures code transformers

slide-101
SLIDE 101

Resources

Where to find out more

slide-102
SLIDE 102

Resources

Resources on Dart

– Website:

http://www.dartlang.org

– Specification:

  • https://www.dartlang.org/docs/spec/latest/dart-language-

specification.html

  • ECMA 408 (https://www.ecma-

international.org/publications/standards/Ecma-408.htm)

– Tutorials:

https://www.dartlang.org/docs/tutorials/

slide-103
SLIDE 103

Credentials

Who is this guy?

– Principal -- Neward & Associates – Director, Smartsheet.com

  • Developer Relations
  • Solutions Engineering

– Microsoft MVP; Java Expert – Author

Professional F# 2.0 (w/Erickson, et al; Wrox, 2010) Effective Enterprise Java (Addison-Wesley, 2004) SSCLI Essentials (w/Stutz, et al; OReilly, 2003) Server-Based Java Programming (Manning, 2000)

– Blog: http://blogs.tedneward.com – Twitter: @tedneward – For more, see http://www.newardassociates.com