Slide 1

Slide 1 text

Fast Prototypes with Flutter + Kotlin/Native JB Lorenzo OLX Group, Berlin

Slide 2

Slide 2 text

we fuel local economies by making it super easy for anyone to buy or sell almost anything through our platforms Our Mission

Slide 3

Slide 3 text

Who We Are we operate a network of market-leading trading platforms in over 40 countries that are used by more than 350 million people every month to buy and sell almost anything

Slide 4

Slide 4 text

Our Numbers brands 17 + people 500 0+ daily listings 1M + offices 35 daily events 4B + daily notifications 50M + monthly users 350M + countries 43 shopping app (20+ markets) #1

Slide 5

Slide 5 text

The Story OLX P&Tech Conference App The Team

Slide 6

Slide 6 text

The Story

Slide 7

Slide 7 text

Outline: - Why? - How? (to Setup) - How? (to use it) - What? (pitfalls, considerations)

Slide 8

Slide 8 text

Why Flutter + Kotlin/Native

Slide 9

Slide 9 text

Architecture

Slide 10

Slide 10 text

How do I start What project structure works?

Slide 11

Slide 11 text

What project structure works? - Kotlin/Native_version = ‘0.8.2’ - kotlin_version = ‘1.2.31' - flutter: sdk: flutter - google_sign_in: 3.0.5 - url_launcher: ^3.0.3 - device_calendar: 0.0.6

Slide 12

Slide 12 text

Flutter project structure

Slide 13

Slide 13 text

settings.gradle Flutter project structure How do I + Kotlin/Native

Slide 14

Slide 14 text

settings.gradle Flutter project structure Kotlin/Native

Slide 15

Slide 15 text

// settings.gradle include ':app' def flutterProjectRoot =rootProject.projectDir.parentFile.toPath() def plugins =new Properties() def pluginsFile =new File(flutterProjectRoot.toFile(), '.flutter-plugins') if (pluginsFile.exists()) { pluginsFile.withReader('UTF-8') { reader -> plugins.load(reader) } } plugins.each { name, path -> def pluginDirectory=flutterProjectRoot.resolve(path).resolve('android').toFile() include":$name" project(":$name").projectDir =pluginDirectory }

Slide 16

Slide 16 text

// settings.gradle include ':app' // ... some flutter directives include ':common' includė ':ios' project(":ios").projectDir = new File("ios") project(":common").projectDir = new File("common")

Slide 17

Slide 17 text

// android/build.gradle rootProject.buildDir = '../build' subprojects { project.buildDir = "${rootProject.buildDir}/${project.name}" }

Slide 18

Slide 18 text

// ios/build.gradle buildscript { // ... kotlin-native classpath and repositories } apply plugin: 'konan' konan.targets = ['iphone', 'iphone_sim'] konanArtifacts { framework('YourFrameworkName') { enableMultiplatform true } } dependencies { expectedBy project(':common') }

Slide 19

Slide 19 text

// common/build.gradle // ... kotlin-gradle classpath apply plugin: 'kotlin-platform-common' group = 'com.olxgroup.olxconf' // ... repositories dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib-common: $kotlin_version" }

Slide 20

Slide 20 text

No content

Slide 21

Slide 21 text

Now we've setup - settings.gradle - android/build.gradle - ios/build.gradle - common/build.gradle - framework in iOS

Slide 22

Slide 22 text

* For Glueing code

Slide 23

Slide 23 text

Now we can start coding in Flutter + Kotlin/Native ... How to use it?

Slide 24

Slide 24 text

iOS // AppDelegate.swift import YourFrameworkName // from Kotlin-Native // ... let channel = FlutterMethodChannel.init(name: "/channel", binaryMessenger: controller) channel.setMethodCallHandler({(call: FlutterMethodCall, result: @escaping FlutterResult) -> Void in // Process call.method and result }); GeneratedPluginRegistrant.register(with: self)

Slide 25

Slide 25 text

Android // MainActivity.kt GeneratedPluginRegistrant.registerWith(this) MethodChannel(flutterView, CHANNEL).setMethodCallHandler { call, result -> when (call.method) { "methodName" -> doSomethingWith(result) } }

Slide 26

Slide 26 text

Pitfalls * Packing and Unpacking (Object passing into FlutterChannel) * Kotlin Companion objects in Swift * Kotlin-Native version dependent support (e.g. for arm32) * Kotlin-Native without JVM is not typical (missing standard libraries, e.g. url parsing)

Slide 27

Slide 27 text

The Result

Slide 28

Slide 28 text

Takeaways * Flutter is awesome for fast prototypes * Flutter and Kotlin/Native are still in beta but is usable already though with some limitations * Kotlin/Native works well to reduce the amount of platform specific code * Some glue code needs to be written to pass around/ serialize objects * Don’t be afraid to try out new technologies (but …)

Slide 29

Slide 29 text

THANK YOU! Questions? Get in touch with us olxgroup.com tech.olx.com olxtechberlin [email protected] jblorenzo