Flutter
Flutter
Flutter
Holo Material
Design Design
Android View
API Design
(View.java)
UI Bugfixes and Improvements
● Project Butter
● RecyclerView
● Design support library
● Instant Run
● Databinding in XML layouts
● Vector Drawables
● ...and thousands small fixes every release
My smartphone is lagging
- Every Android user ‘17
Android UI Framework
● >10 years old
● The Java API hasn’t seen major changes
● No architectural changes, we are still using
android.view to render our UIs
● Feels old
○ XML still “best practice”
○ No virtual dom
The entire UI architecture is
wrong from the start.
Erik Hellman
@ErikHellman
Flutter
120
60 FPS UI of the Future
What is Flutter?
● A mobile app SDK containing
flutter.io
○ complete UI Framework for mobile apps
○ huge Widget catalog
○ Tools
● Allows building beautiful mobile apps
● Platform independent, currently supporting
Android, iOS and Fuchsia
● Uses Dart - Easy to learn language by Google
Flutters goals
● Beautiful fluid UIs
● Run same UI on multiple platforms, perfect for
brand-first designs
● high-performance apps that feel natural on different
platforms
● Be productive
flutter.io
Flutter highlights
● Super performant, 120fps without optimizations
● Fast development - Hot Reload
● Modern, reactive framework like React
flutter.io
Flutter is not yet another
Cross-Platform SDK
● Engine is shipped in apk (∽7.5 Mb)
● No bridge needed, direct drawing to platform canvas
● Doesn’t use OEM widgets
● Ships SDK with the app, no fragmentation or
compatibility issues
App Platform OS
Bridge
JavaScript
System Services
(Location, Bluetooth, Audio, Camera,
Sensors, etc.)
Canvas
Widget
Flutter
Rendering Events
Native
Flutter Code
System Services
Platform
(Location, Bluetooth, Audio, Camera,
Channels
Sensors, etc.)
What is Dart?
● Java like language - easy to learn
● aimed to replace Javascript (2010) dartlang.org
● DartVM
● Javascript compiler (dart2js)
● Start developing
First Steps - Hello Flutter
● Create a new project
$ flutter create myapp
Canvas
Widget
Flutter
Rendering Events
Native
Flutter Code
System Services
Platform
(Location, Bluetooth, Audio, Camera,
Channels
Sensors, etc.)
What are Widgets?
class PaddedText extends StatelessWidget {
● Widgets are immutable
final String _data;
declarations of parts of the UI
PaddedText(this._data, {Key key})
● Like a <div/> : super(key: key);
Flutter Android
Widgets
(immutable)
Canvas
Widget
Flutter
Rendering Events
Native
Flutter Code
System Services
Platform
(Location, Bluetooth, Audio, Camera,
Channels
Sensors, etc.)
Communication between
Android and Flutter
● FlutterView (extends SurfaceView) is placed
fullscreen in your Activity.
● Plugins can be initialized which register a MethodChannel
on the FlutterView.
● These MethodChannel are invoked by the plugins Dart
API
SharedPrefs Plugin example
Dart part of plugin
String batteryLevel;
try {
final int result =
await methodChannel.invokeMethod('getBatteryLevel');
batteryLevel = 'Battery level: $result%.';
} on PlatformException {
batteryLevel = "Failed to get battery level.";
}
SharedPrefs Plugin example
Android Kotlin part of plugin
if (level != -1) {
result.success(level)
} else {
result.error("UNAVAILABLE", "Battery level not available.", null)
}
} else {
result.notImplemented()
}
}
MethodChannel(flutterView, "samples.flutter.io/battery").setMethodCallHandler(msgHandler)
Plugins
● Communication is contract based, can’t be type safe
○ Method name is String
○ Method args are named and dynamic
(Map<String, dynamic>)
● MethodChannel work in both directions
Official Plugins
github.com/flutter/plugins
Shared code with Dart
● FlutterView is required to run dart code. You always
need an Activity.
● You can’t run Dart code in a background service
● You can’t reuse network or parsing logic in your
JobScheduler
● Unclear if this will ever work
Is flutter production ready?
No, but...
...the Flutter team is very aware of it and
working hard to make it production ready.
Flutter in Production
Hamilton Newsvoice
What’s missing
- Retrofit/OkHttp and a persistent cache
- Google Maps
- Push Notifications (iOS) sometimes give no callback
- No “headless flutter”
Room for improvement
- brackets hell, no DSL
- workaround 'closing labels'
in VS Code in IntelliJ maybe?!
- Flatten with variables,
extract methods
- One missing comma,
breaks code completion
Openness of Dart/Flutter/Fuchsia
● Everything is open source
● Bug trackers are public and used by Googlers
● Dartlang newsletter inside sdk repository with detailed
language decisions for Dart 2.0
fuchsia.googlesource.com
Fuchsia Roadmap
Android
Oct Sep
2003 2008 2011 2014 2017
Jun Jul
2016 2021