Flutter - YOW! Conferences · Flutter makes it easy and fast to build beautiful mobile apps....

74
Flutter Kasper Lund, Google

Transcript of Flutter - YOW! Conferences · Flutter makes it easy and fast to build beautiful mobile apps....

Page 1: Flutter - YOW! Conferences · Flutter makes it easy and fast to build beautiful mobile apps. Flutter is a new mobile app SDK to help developers and designers build modern mobile apps

FlutterKasper Lund, Google

Page 2: Flutter - YOW! Conferences · Flutter makes it easy and fast to build beautiful mobile apps. Flutter is a new mobile app SDK to help developers and designers build modern mobile apps
Page 3: Flutter - YOW! Conferences · Flutter makes it easy and fast to build beautiful mobile apps. Flutter is a new mobile app SDK to help developers and designers build modern mobile apps
Page 4: Flutter - YOW! Conferences · Flutter makes it easy and fast to build beautiful mobile apps. Flutter is a new mobile app SDK to help developers and designers build modern mobile apps

Page 5: Flutter - YOW! Conferences · Flutter makes it easy and fast to build beautiful mobile apps. Flutter is a new mobile app SDK to help developers and designers build modern mobile apps

The best way to build for mobile?

Page 6: Flutter - YOW! Conferences · Flutter makes it easy and fast to build beautiful mobile apps. Flutter is a new mobile app SDK to help developers and designers build modern mobile apps

We need to talk about American politics...

Page 7: Flutter - YOW! Conferences · Flutter makes it easy and fast to build beautiful mobile apps. Flutter is a new mobile app SDK to help developers and designers build modern mobile apps
Page 8: Flutter - YOW! Conferences · Flutter makes it easy and fast to build beautiful mobile apps. Flutter is a new mobile app SDK to help developers and designers build modern mobile apps

The Founding Father Alexander Hamilton's life is now a hip-hop musical...

Page 9: Flutter - YOW! Conferences · Flutter makes it easy and fast to build beautiful mobile apps. Flutter is a new mobile app SDK to help developers and designers build modern mobile apps

Hamilton!

Page 10: Flutter - YOW! Conferences · Flutter makes it easy and fast to build beautiful mobile apps. Flutter is a new mobile app SDK to help developers and designers build modern mobile apps

So you have have one really popular show.

What more do you need?

Page 11: Flutter - YOW! Conferences · Flutter makes it easy and fast to build beautiful mobile apps. Flutter is a new mobile app SDK to help developers and designers build modern mobile apps
Page 12: Flutter - YOW! Conferences · Flutter makes it easy and fast to build beautiful mobile apps. Flutter is a new mobile app SDK to help developers and designers build modern mobile apps

When do you need it?

Now.

Page 13: Flutter - YOW! Conferences · Flutter makes it easy and fast to build beautiful mobile apps. Flutter is a new mobile app SDK to help developers and designers build modern mobile apps

Hurry up and build two great apps!

● We need a super productive framework and developer environment● We need a platform that supports custom UIs really well● We need a high-performance solution that supports beautiful apps

Page 14: Flutter - YOW! Conferences · Flutter makes it easy and fast to build beautiful mobile apps. Flutter is a new mobile app SDK to help developers and designers build modern mobile apps

Flutter

Page 15: Flutter - YOW! Conferences · Flutter makes it easy and fast to build beautiful mobile apps. Flutter is a new mobile app SDK to help developers and designers build modern mobile apps

http://flutter.io/

Page 16: Flutter - YOW! Conferences · Flutter makes it easy and fast to build beautiful mobile apps. Flutter is a new mobile app SDK to help developers and designers build modern mobile apps

Mobile SDKs

Compiled to native

MVC/MVVM

Reactive

Interpreted (JavaScript)

iOS SDKAndroid SDK

Page 17: Flutter - YOW! Conferences · Flutter makes it easy and fast to build beautiful mobile apps. Flutter is a new mobile app SDK to help developers and designers build modern mobile apps

Mobile SDKs

MVC/MVVM

Reactive

iOS SDKAndroid SDK

Titanium, Cordova, PhoneGap, Ionic, ...

Compiled to native Interpreted (JavaScript)

Page 18: Flutter - YOW! Conferences · Flutter makes it easy and fast to build beautiful mobile apps. Flutter is a new mobile app SDK to help developers and designers build modern mobile apps

Mobile SDKs

MVC/MVVM

Reactive

iOS SDKAndroid SDK

Titanium, Cordova, PhoneGap, Ionic, ...

React Native

Compiled to native Interpreted (JavaScript)

Page 19: Flutter - YOW! Conferences · Flutter makes it easy and fast to build beautiful mobile apps. Flutter is a new mobile app SDK to help developers and designers build modern mobile apps

Mobile SDKs

MVC/MVVM

Reactive

iOS SDKAndroid SDK

Titanium, Cordova, PhoneGap, Ionic, ...

Flutter React Native

Compiled to native Interpreted (JavaScript)

Page 20: Flutter - YOW! Conferences · Flutter makes it easy and fast to build beautiful mobile apps. Flutter is a new mobile app SDK to help developers and designers build modern mobile apps

...

Flutter’s layered architecture

Page 21: Flutter - YOW! Conferences · Flutter makes it easy and fast to build beautiful mobile apps. Flutter is a new mobile app SDK to help developers and designers build modern mobile apps

Flutter comes with lots of Material Design widgets...

Page 22: Flutter - YOW! Conferences · Flutter makes it easy and fast to build beautiful mobile apps. Flutter is a new mobile app SDK to help developers and designers build modern mobile apps

Let us see it live...

$ flutter devicesemulator-5554 • android-x64 (7.1.1)$ flutter run -d emulator-5554

Page 23: Flutter - YOW! Conferences · Flutter makes it easy and fast to build beautiful mobile apps. Flutter is a new mobile app SDK to help developers and designers build modern mobile apps

“What I really like about Flutter, is their beautiful set of Material Design widgets.”

https://medium.com/@aubykhan/how-i-built-a-cross-platform-connected-app-in-7-days-93728a987424

Page 24: Flutter - YOW! Conferences · Flutter makes it easy and fast to build beautiful mobile apps. Flutter is a new mobile app SDK to help developers and designers build modern mobile apps

Custom UIs are really quite popular

Page 25: Flutter - YOW! Conferences · Flutter makes it easy and fast to build beautiful mobile apps. Flutter is a new mobile app SDK to help developers and designers build modern mobile apps

Doing custom is hard

Doing custom twice is painful

Traditionally

Page 26: Flutter - YOW! Conferences · Flutter makes it easy and fast to build beautiful mobile apps. Flutter is a new mobile app SDK to help developers and designers build modern mobile apps

Flutter supports custom UIs extremely well because of the platform layering

Page 27: Flutter - YOW! Conferences · Flutter makes it easy and fast to build beautiful mobile apps. Flutter is a new mobile app SDK to help developers and designers build modern mobile apps
Page 28: Flutter - YOW! Conferences · Flutter makes it easy and fast to build beautiful mobile apps. Flutter is a new mobile app SDK to help developers and designers build modern mobile apps

Doing custom is easy

Doing custom twice is not needed

Flutter

Page 29: Flutter - YOW! Conferences · Flutter makes it easy and fast to build beautiful mobile apps. Flutter is a new mobile app SDK to help developers and designers build modern mobile apps

“Running at 60 fps, user interfaces created with Flutter perform far better than those created with other cross-platform development frameworks.”

https://code.tutsplus.com/tutorials/developing-an-android-app-with-flutter--cms-28270

Page 30: Flutter - YOW! Conferences · Flutter makes it easy and fast to build beautiful mobile apps. Flutter is a new mobile app SDK to help developers and designers build modern mobile apps

Dart

Page 31: Flutter - YOW! Conferences · Flutter makes it easy and fast to build beautiful mobile apps. Flutter is a new mobile app SDK to help developers and designers build modern mobile apps

Dart is the tech stack of choice for Google’s largest business

Page 32: Flutter - YOW! Conferences · Flutter makes it easy and fast to build beautiful mobile apps. Flutter is a new mobile app SDK to help developers and designers build modern mobile apps
Page 33: Flutter - YOW! Conferences · Flutter makes it easy and fast to build beautiful mobile apps. Flutter is a new mobile app SDK to help developers and designers build modern mobile apps

Dart translates to JavaScript and runs in all modern browsers

Page 34: Flutter - YOW! Conferences · Flutter makes it easy and fast to build beautiful mobile apps. Flutter is a new mobile app SDK to help developers and designers build modern mobile apps

main() { var person = new Person("Kasper"); print("Hello $person");}

class Person { String name; Person(this.name); toString() => name;}

A taste of Dart...

Page 35: Flutter - YOW! Conferences · Flutter makes it easy and fast to build beautiful mobile apps. Flutter is a new mobile app SDK to help developers and designers build modern mobile apps

The Dart language

● Unsurprising and object-oriented ● Class-based single inheritance● Familiar syntax with lexical scoping● Sound type system NEW!

Page 36: Flutter - YOW! Conferences · Flutter makes it easy and fast to build beautiful mobile apps. Flutter is a new mobile app SDK to help developers and designers build modern mobile apps

Ahead-of-time compilation

*.dart compiler

.apk

.js

Page 37: Flutter - YOW! Conferences · Flutter makes it easy and fast to build beautiful mobile apps. Flutter is a new mobile app SDK to help developers and designers build modern mobile apps

Dart compiles to native machine code

...ldr r1, [sp]ldr d0, [r1, #3]vcmpd d0, d0vmstatbvs L0vcvtid s2, d0vmovrs r0, s2adds r0, r0, r0bvs L1vcvtdi d1, s2vcmpd d0, d1vmstatbxeq lr

L0: ldr r0, [r1, #3]ldr r1, [r1, #7]eor r0, r0, r1...

Page 38: Flutter - YOW! Conferences · Flutter makes it easy and fast to build beautiful mobile apps. Flutter is a new mobile app SDK to help developers and designers build modern mobile apps

“The UI is butter smooth ... I have never seen such a smooth Android app.”

Pascal Welsch, Speaker at Droidcon Berlin

Page 39: Flutter - YOW! Conferences · Flutter makes it easy and fast to build beautiful mobile apps. Flutter is a new mobile app SDK to help developers and designers build modern mobile apps

… but making sausages is quite involved!

Page 40: Flutter - YOW! Conferences · Flutter makes it easy and fast to build beautiful mobile apps. Flutter is a new mobile app SDK to help developers and designers build modern mobile apps

Pay as you go: Just-in-time compilation

● Compile the application as it executes● Avoid paying the compilation cost up front● Only compile the parts actually executed

Page 41: Flutter - YOW! Conferences · Flutter makes it easy and fast to build beautiful mobile apps. Flutter is a new mobile app SDK to help developers and designers build modern mobile apps

Stand back while I hack this thing...

Page 42: Flutter - YOW! Conferences · Flutter makes it easy and fast to build beautiful mobile apps. Flutter is a new mobile app SDK to help developers and designers build modern mobile apps

“Coding with Flutter the past week has brought back the joy of mobile development for me.”

https://traversoft.com/blog/2017/08/08/conference-app-flutter/

Page 43: Flutter - YOW! Conferences · Flutter makes it easy and fast to build beautiful mobile apps. Flutter is a new mobile app SDK to help developers and designers build modern mobile apps

Constructing widget trees in Flutter appear expensive – is it?

Concerned?

Page 44: Flutter - YOW! Conferences · Flutter makes it easy and fast to build beautiful mobile apps. Flutter is a new mobile app SDK to help developers and designers build modern mobile apps

Excited!

No!

Page 45: Flutter - YOW! Conferences · Flutter makes it easy and fast to build beautiful mobile apps. Flutter is a new mobile app SDK to help developers and designers build modern mobile apps

Free space is contiguous

filled free

Page 46: Flutter - YOW! Conferences · Flutter makes it easy and fast to build beautiful mobile apps. Flutter is a new mobile app SDK to help developers and designers build modern mobile apps

Allocate by bumping a single pointer ...

filled freenew

Page 47: Flutter - YOW! Conferences · Flutter makes it easy and fast to build beautiful mobile apps. Flutter is a new mobile app SDK to help developers and designers build modern mobile apps

… and initializing the allocated space

filled free

Page 48: Flutter - YOW! Conferences · Flutter makes it easy and fast to build beautiful mobile apps. Flutter is a new mobile app SDK to help developers and designers build modern mobile apps

Allocation in Dart

Lock freeSimple

Fast

Page 49: Flutter - YOW! Conferences · Flutter makes it easy and fast to build beautiful mobile apps. Flutter is a new mobile app SDK to help developers and designers build modern mobile apps

Concerned?

How much do we have to pay for collecting the garbage?

Page 50: Flutter - YOW! Conferences · Flutter makes it easy and fast to build beautiful mobile apps. Flutter is a new mobile app SDK to help developers and designers build modern mobile apps

conservative precise

Where have all the pointers gone?

Idea: treat everything that looks like a pointer as such- can’t distinguish ints from pointers- can’t update pointers, because they might be ints

Dart

Page 51: Flutter - YOW! Conferences · Flutter makes it easy and fast to build beautiful mobile apps. Flutter is a new mobile app SDK to help developers and designers build modern mobile apps

Semi-space collector

live objects

Page 52: Flutter - YOW! Conferences · Flutter makes it easy and fast to build beautiful mobile apps. Flutter is a new mobile app SDK to help developers and designers build modern mobile apps

“from” space

Semi-space collector

“to” space

live objects

Page 53: Flutter - YOW! Conferences · Flutter makes it easy and fast to build beautiful mobile apps. Flutter is a new mobile app SDK to help developers and designers build modern mobile apps

“from” space

Semi-space collector

“to” space

live objects

copy

Page 54: Flutter - YOW! Conferences · Flutter makes it easy and fast to build beautiful mobile apps. Flutter is a new mobile app SDK to help developers and designers build modern mobile apps

“from” space

Semi-space collector

“to” space

live objects

copy

Page 55: Flutter - YOW! Conferences · Flutter makes it easy and fast to build beautiful mobile apps. Flutter is a new mobile app SDK to help developers and designers build modern mobile apps

“from” space

Semi-space collector

“to” space

live objects

copy

Page 56: Flutter - YOW! Conferences · Flutter makes it easy and fast to build beautiful mobile apps. Flutter is a new mobile app SDK to help developers and designers build modern mobile apps

“from” space

Semi-space collector

“to” space

live objects

Page 57: Flutter - YOW! Conferences · Flutter makes it easy and fast to build beautiful mobile apps. Flutter is a new mobile app SDK to help developers and designers build modern mobile apps

“from” space

Semi-space collector

“to” space

live objects

Page 58: Flutter - YOW! Conferences · Flutter makes it easy and fast to build beautiful mobile apps. Flutter is a new mobile app SDK to help developers and designers build modern mobile apps

“to” space

Semi-space collector

“from” space

live objects

contiguous free space

Page 59: Flutter - YOW! Conferences · Flutter makes it easy and fast to build beautiful mobile apps. Flutter is a new mobile app SDK to help developers and designers build modern mobile apps

conservative precise

Dart provides precise garbage collection for Flutter

Idea: allow moving objects and compacting- enables really fast allocations- enables really fast garbage collections

Dart

Page 60: Flutter - YOW! Conferences · Flutter makes it easy and fast to build beautiful mobile apps. Flutter is a new mobile app SDK to help developers and designers build modern mobile apps

root

Live and dead objects in the object soup (usually called the heap)

Page 61: Flutter - YOW! Conferences · Flutter makes it easy and fast to build beautiful mobile apps. Flutter is a new mobile app SDK to help developers and designers build modern mobile apps

root

Live and dead objects in the object soup (usually called the heap)

“to” space

Page 62: Flutter - YOW! Conferences · Flutter makes it easy and fast to build beautiful mobile apps. Flutter is a new mobile app SDK to help developers and designers build modern mobile apps

root

Let’s start at the root

“to” space

forwarding pointer

Page 63: Flutter - YOW! Conferences · Flutter makes it easy and fast to build beautiful mobile apps. Flutter is a new mobile app SDK to help developers and designers build modern mobile apps

root

When done with the roots, we scan through “to” space

“to” space

Page 64: Flutter - YOW! Conferences · Flutter makes it easy and fast to build beautiful mobile apps. Flutter is a new mobile app SDK to help developers and designers build modern mobile apps

root

We continue scanning through “to” space ...

“to” space

Page 65: Flutter - YOW! Conferences · Flutter makes it easy and fast to build beautiful mobile apps. Flutter is a new mobile app SDK to help developers and designers build modern mobile apps

root

… as long as we’re making progress (copying over objects)

“to” space

Page 66: Flutter - YOW! Conferences · Flutter makes it easy and fast to build beautiful mobile apps. Flutter is a new mobile app SDK to help developers and designers build modern mobile apps

root

… and we’re done!

“to” space

Done

We never touched any of the dead

objects!

Page 67: Flutter - YOW! Conferences · Flutter makes it easy and fast to build beautiful mobile apps. Flutter is a new mobile app SDK to help developers and designers build modern mobile apps

Garbage collection of

short-lived objectsZero cost for dead objectsNon-recursive

SimpleFast

Now I should really tell you about generational garbage

collection...

Page 68: Flutter - YOW! Conferences · Flutter makes it easy and fast to build beautiful mobile apps. Flutter is a new mobile app SDK to help developers and designers build modern mobile apps

Flutter’s widget construction pattern is super well supported by Dart!

Page 69: Flutter - YOW! Conferences · Flutter makes it easy and fast to build beautiful mobile apps. Flutter is a new mobile app SDK to help developers and designers build modern mobile apps

Dart allows deploying fast machine code

Dart enables hot reload in development

Dart deals efficiently with tons of widgets

Dart for Flutter

Page 70: Flutter - YOW! Conferences · Flutter makes it easy and fast to build beautiful mobile apps. Flutter is a new mobile app SDK to help developers and designers build modern mobile apps

Now back to Hamilton...

Page 71: Flutter - YOW! Conferences · Flutter makes it easy and fast to build beautiful mobile apps. Flutter is a new mobile app SDK to help developers and designers build modern mobile apps

After a short three months...

One simple codebase, two great apps(Android and iOS)

Page 72: Flutter - YOW! Conferences · Flutter makes it easy and fast to build beautiful mobile apps. Flutter is a new mobile app SDK to help developers and designers build modern mobile apps
Page 73: Flutter - YOW! Conferences · Flutter makes it easy and fast to build beautiful mobile apps. Flutter is a new mobile app SDK to help developers and designers build modern mobile apps

https://flutter.io/

Flutter makes it easy and fast to build beautiful mobile apps.

Flutter is a new mobile app SDK to help developers and designers build modern mobile apps for iOS and Android.

Flutter is available as an open-source,alpha release.

Flutter is used by Google and others in production.

Page 74: Flutter - YOW! Conferences · Flutter makes it easy and fast to build beautiful mobile apps. Flutter is a new mobile app SDK to help developers and designers build modern mobile apps

Thank you!https://flutter.io/