45
Introduction to the Dart lang Jana Moudrá

Introduction to the Dart language

Embed Size (px)

DESCRIPTION

My presentation from event: Introduction to the Dart language organized by GDG SSPŠ.

Citation preview

Page 1: Introduction to the Dart language

Introduction to the

Dart langJana Moudrá

Page 2: Introduction to the Dart language

Co-Founder at JuicymoOrganizer at GDG ČVUT Prague/GDG Prague

Interested in Web, Android, Design, Dart

about.me/janamou

About Me

Page 3: Introduction to the Dart language

about.me/janamou

Page 4: Introduction to the Dart language

about.me/janamou

1.3.6

Page 5: Introduction to the Dart language

Open-sourceLanguage for the Web

For better performanceGoals to replace JavaScriptReady for standardization

about.me/janamou

Page 6: Introduction to the Dart language

Dartium: Chromium with Dart VM

about.me/janamou

Page 7: Introduction to the Dart language

Compiled into JavaScript works

in all modern browsers

about.me/janamou

Page 8: Introduction to the Dart language

Object Oriented Easy to learn Optional types

ModularCompiles to JavaScript

about.me/janamou

Page 9: Introduction to the Dart language

Client Server

about.me/janamou

Page 10: Introduction to the Dart language

Performance

Page 11: Introduction to the Dart language

Dart Performancewww.dartlang.org/performance/

Page 12: Introduction to the Dart language

Language

Page 13: Introduction to the Dart language

Optional typesEvery variable

is objectTop level main()

function

Checked and Production

modesSyntactic sugar

Named constructors

… and more

about.me/janamou

Streams Futures HTML

Page 14: Introduction to the Dart language

var x = 10;var y = 20;

or

num x = 10;num y = 20;

Optional types

about.me/janamou

Page 15: Introduction to the Dart language

void main() { print("Hello world Dart!");

}

Top level main() function

about.me/janamou

Page 16: Introduction to the Dart language

class Person {

String firstName;

String lastName;

int age;

Person(this.firstName, this.lastName);

}

void main() {

Person person = new Person("Jana", "Moudrá");

}

Syntactic sugar

about.me/janamou

Page 17: Introduction to the Dart language

class Person {

String firstName;

String lastName;

int age;

Person(this.firstName, this.lastName);

Person.withAge(this.lastName, this.age);

}

void main() {

Person person = new Person.withAge("Moudrá", 25);

}

Named constructor

about.me/janamou

Page 18: Introduction to the Dart language

class Person {

String _firstName;

String _lastName;

int _age;

Person(this.firstName, this.lastName);

Person.withAge(this.lastName, this.age);

int get age => _age;

set age(int age) => _age = age;

}

Getter/Setter

about.me/janamou

Page 19: Introduction to the Dart language

void main() {

querySelector("#my-button")

..text = "Open Window" ..onClick.listen(openWindow);}

Cascade operator

about.me/janamou

Page 20: Introduction to the Dart language

someFunc()

.then(printValue) .catchError(printError);

Futures I.

about.me/janamou

Page 21: Introduction to the Dart language

HttpRequest.getString('shapes.json')

.then((String jsonString) { print(jsonString);

})

.catchError((Error error) { print(error.toString());

});

Futures II.

about.me/janamou

Page 22: Introduction to the Dart language

Tools

Page 23: Introduction to the Dart language

about.me/janamou

Dart Editor Dartium Dart SDK

Page 24: Introduction to the Dart language

Dart Editor

Page 25: Introduction to the Dart language

Dart VMLibraries

Command Line Tools

Dart SDK

Page 26: Introduction to the Dart language

Dart VMLibraries

Command Line Tools

Dart SDK

dart2js dartanalyzer pubdocgen

Page 27: Introduction to the Dart language

Libraries

Page 28: Introduction to the Dart language

dart:coredart:htmldart:math

dart:convertdart:js

dart:web_gl

… and more on https://api.dartlang.org/apidocs/

about.me/janamou

Page 29: Introduction to the Dart language

import 'dart:html';

ButtonElement myButton;

void main() {

myButton = querySelector('#myButton');

myButton.onClick.listen(updateText);

}

void updateText(Event event) {

myButton.text = "Hello world Dart!";

}

dart:html

about.me/janamou

Page 30: Introduction to the Dart language

dart:convert

about.me/janamou

import 'dart:convert';

void main() {

String jsonString =

'{"name": "Jana", "surname": "Moudra"}';

Map jsonMap = JSON.decode(jsonString);

print(jsonMap["name"]); //prints Jana

print(jsonMap["surname"]); //prints Moudra

}

Page 31: Introduction to the Dart language

dart:js

about.me/janamou

<script type="text/javascript">

var Person = function(name, surname) {

this.name = name;

this.surname = surname;

this.sayHello = function(){

alert("Hello!");

}

};

</script>

Page 32: Introduction to the Dart language

dart:js

about.me/janamou

import 'dart:js';

void main() {

var person = new JsObject(context['Person'],

["Jana", "Moudra"]);

print(person["name"]);

print(person["surname"]);

person.callMethod("sayHello");

}

Page 33: Introduction to the Dart language

AngularDartPolymer.dart

StageXLthree.dart

vector_math

… and more on https://pub.dartlang.org/

about.me/janamou

Page 34: Introduction to the Dart language

How to start?

Page 35: Introduction to the Dart language

How to start?www.dartlang.org

Page 36: Introduction to the Dart language
Page 37: Introduction to the Dart language

GET STARTEDwww.dartlang.org/codelabs/darrrt/

Page 38: Introduction to the Dart language

DOCS > TUTORIALSwww.dartlang.org/docs/tutorials/

Page 39: Introduction to the Dart language

DART API REFERENCEhttps://api.dartlang.org/apidocs/

DOCS > DART: UP AND RUNNINGwww.dartlang.org/docs/dart-up-and-running/

Page 40: Introduction to the Dart language

DOCS > API REFERENCEhttps://api.dartlang.org/apidocs/channels/stable/dartdoc-viewer/home

Page 41: Introduction to the Dart language

PUBhttps://pub.dartlang.org/

Page 42: Introduction to the Dart language

SAMPLESwww.dartlang.org/samples/

Page 43: Introduction to the Dart language
Page 44: Introduction to the Dart language

Thank You!and happy Dart coding :-)

about.me/janamou

Page 45: Introduction to the Dart language

https://www.dartlang.org/http://news.dartlang.org/https://pub.dartlang.org/

https://github.com/dart-langhttps://plus.google.com/+dartlang/

https://www.dartlang.org/articles/idiomatic-dart/

Dart Resources