Slide 1

Slide 1 text

Flutter For Android Developers Burhanuddin Rashid

Slide 2

Slide 2 text

What is Flutter ?

Slide 3

Slide 3 text

● Google’s mobile SDK. ● High-quality. ● Native interfaces on iOS/Android. ● Record time. ● Dart.

Slide 4

Slide 4 text

Why Flutter ?

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

Hot Reload

Slide 7

Slide 7 text

Material Design

Slide 8

Slide 8 text

Native Performance

Slide 9

Slide 9 text

Why Android Developers ?

Slide 10

Slide 10 text

No content

Slide 11

Slide 11 text

Migrating

Slide 12

Slide 12 text

https://flutter.io/get-started/editor/

Slide 13

Slide 13 text

No content

Slide 14

Slide 14 text

No content

Slide 15

Slide 15 text

Activity

Slide 16

Slide 16 text

AndroidManifest.xml Activity

Slide 17

Slide 17 text

No content

Slide 18

Slide 18 text

Toolbar Scaffold import 'package:flutter/material.dart'; void main() => runApp(new MaterialApp( home: new Scaffold( backgroundColor: Colors.yellowAccent, ), )); appBar: new AppBar( title: new Text("My Title"), ), body: new Container( color: Colors.red, ), Activity

Slide 19

Slide 19 text

Menu override fun onCreateOptionsMenu(menu: Menu?): Boolean { menuInflater.inflate(R.menu.sample_menu, menu) return true } override fun onOptionsItemSelected(item: MenuItem): Boolean { when (item.itemId) { } return super.onOptionsItemSelected(item) } new Scaffold( appBar: new AppBar( title: new Text("My Title"), ), ) Appbar actions: [ ], new IconButton( icon: new Icon(Icons.shopping_cart), onPressed: () {}, ), new IconButton( icon: Icon(Icons.monetization_on), onPressed: () {}, ) Activity

Slide 20

Slide 20 text

Drawer new Scaffold( ) Scaffold Activity drawer: new Drawer(), bottomNavigationBar: new BottomNavigationBar( items: [ new BottomNavigationBarItem(), new BottomNavigationBarItem() ] ), floatingActionButton: new FloatingActionButton( onPressed: () {}, child: new Icon(Icons.add), ), Bottom Navigation Floating Action

Slide 21

Slide 21 text

No content

Slide 22

Slide 22 text

LinearLayout

Slide 23

Slide 23 text

Orientation new Scaffold( body: new Container( color: Colors.yellowAccent, child: ), ), ); LinearLayout Row / Column new Row ( children: [ new Icon(Icons.access_time,size: 50.0), new Icon(Icons.pie_chart,size: 100.0), new Icon(Icons.email,size: 50.0) ], new Column ( children: [ new Icon(Icons.access_time,size: 50.0), new Icon(Icons.pie_chart,size: 100.0), new Icon(Icons.email,size: 50.0) ],

Slide 24

Slide 24 text

LinearLayout

Slide 25

Slide 25 text

LinearLayout Match vs Wrap body: new Container( color: Colors.yellowAccent, child: new Row( children: [...], ), ) MainAxizSize mainAxisSize: MainAxisSize.max, mainAxisSize: MainAxisSize.min,

Slide 26

Slide 26 text

LinearLayout

Slide 27

Slide 27 text

LinearLayout Gravity body: new Container( color: Colors.yellowAccent, child: new Row( children: [...], ), ) MainAxisAligment mainAxisAlignment: MainAxisAlignment.start,

Slide 28

Slide 28 text

LinearLayout

Slide 29

Slide 29 text

LinearLayout

Slide 30

Slide 30 text

LinearLayout CrossAxisAligment

Slide 31

Slide 31 text

LinearLayout Weight body: new Container( color: Colors.yellowAccent, child: new Row( children: [ ], ... ), ) Expanded new Expanded( child: new Icon(...), flex: 4, ), new Expanded( child: new Icon(...), flex: 2, ),

Slide 32

Slide 32 text

LinearLayout

Slide 33

Slide 33 text

FrameLayout

Slide 34

Slide 34 text

FrameLayout FrameLayout new Stack( children: [ Container( height: 200.0, width: 200.0, color: Colors.red, ), Container(...), Container(...), Container(...), ], ) Stack

Slide 35

Slide 35 text

FrameLayout

Slide 36

Slide 36 text

Layout Gravity new Stack( children: [ ... ], ) FrameLayout Align Align( child: Container(...), alignment: AlignmentDirectional.topStart, ), Align( child: Container(...), alignment: AlignmentDirectional.topEnd, ), Align( child: Container(...), alignment: AlignmentDirectional.bottomEnd, ),

Slide 37

Slide 37 text

FrameLayout

Slide 38

Slide 38 text

RecycleView

Slide 39

Slide 39 text

Setting up in Android class SampleAdapter() : RecyclerView.Adapter() { override fun onCreateViewHolder(parent: ViewGroup?, viewType: Int): ViewHolder { TODO("not implemented") } override fun getItemCount(): Int { TODO("not implemented") } override fun onBindViewHolder(holder: ViewHolder?, position: Int) { TODO("not implemented") } inner class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) } val llm = LinearLayoutManager(this) rvSample.layoutManager = llm val sampleAdapter = SampleAdapter() rvSample.adapter = sampleAdapter RecycleView

Slide 40

Slide 40 text

ListView new ListView.builder( ) RecycleView itemBuilder: (context, index) { return new Text( " Item no. $index ", style: new TextStyle(fontSize: 24.0), ); }, itemCount: 100, scrollDirection: Axis.horizontal, // Horizontal ListView

Slide 41

Slide 41 text

RecycleView

Slide 42

Slide 42 text

RecycleView

Slide 43

Slide 43 text

Gesture

Slide 44

Slide 44 text

TouchListeners itemView.setOnClickListener { } itemView.setOnLongClickListener { true } itemView.setOnTouchListener { v, event -> true } new GestureDetector( child: ); Gesture GestureDetector new Text("Some Text"), onTap: () { //do something here }, onLongPress: () { //do something here }, onDoubleTap: () { //do something here },

Slide 45

Slide 45 text

List of Listeners this.onHorizontalDragDown, this.onHorizontalDragStart, this.onHorizontalDragUpdate, this.onHorizontalDragEnd, this.onHorizontalDragCancel, this.onPanDown, this.onPanStart, this.onPanUpdate, this.onPanEnd, this.onPanCancel, this.onScaleStart, this.onScaleUpdate, this.onScaleEnd, }) GestureDetector({ Key key, this.child, this.onTapDown, this.onTapUp, this.onTap, this.onTapCancel, this.onDoubleTap, this.onLongPress, this.onVerticalDragDown, this.onVerticalDragStart, this.onVerticalDragUpdate, this.onVerticalDragEnd, this.onVerticalDragCancel, Gesture

Slide 46

Slide 46 text

Summary ● What and Why of Flutter ● Migrating ● Activity (Scaffold) ● LinearLayout (Row/Column) ● FrameLayout (Stack) ● RecycleView (ListView.Builder) ● Gesture (GestureDetector)

Slide 47

Slide 47 text

Just try it out.

Slide 48

Slide 48 text

No content

Slide 49

Slide 49 text

Thank you @ burhanrashid52 Burhanuddin Rashid Flutter for Android Developer Series