Upgrade to Pro — share decks privately, control downloads, hide ads and more …

[Flutter Meetup Tokyo #1] 雰囲気でFlutterやってみた

syarihu
April 18, 2018

[Flutter Meetup Tokyo #1] 雰囲気でFlutterやってみた

Flutter Meetup Tokyo #1 の発表資料です。

syarihu

April 18, 2018
Tweet

More Decks by syarihu

Other Decks in Technology

Transcript

  1. AppBar void main() => runApp(new MyApp()); class MyApp extends StatelessWidget

    { @override Widget build(BuildContext context) { return new MaterialApp( title: '愛工大シャトルバス時刻表', theme: new ThemeData( primarySwatch: Colors.blue, ), home: new MyHomePage(title: '愛工大シャトルバス時刻表 '), ); } }
  2. AppBar void main() => runApp(new MyApp()); class MyApp extends StatelessWidget

    { @override Widget build(BuildContext context) { return new MaterialApp( title: '愛工大シャトルバス時刻表', theme: new ThemeData( primarySwatch: Colors.blue, ), home: new MyHomePage(title: '愛工大シャトルバス時刻表 '), ); } }
  3. AppBar void main() => runApp(new MyApp()); class MyApp extends StatelessWidget

    { @override Widget build(BuildContext context) { return new MaterialApp( title: '愛工大シャトルバス時刻表', theme: new ThemeData( primarySwatch: Colors.blue, ), home: new MyHomePage(title: '愛工大シャトルバス時刻表 '), ); } }
  4. AppBar void main() => runApp(new MyApp()); class MyApp extends StatelessWidget

    { @override Widget build(BuildContext context) { return new MaterialApp( title: '愛工大シャトルバス時刻表', theme: new ThemeData( primarySwatch: Colors.blue, ), home: new MyHomePage(title: '愛工大シャトルバス時刻表 '), ); } }
  5. AppBar class MyHomePage extends StatefulWidget { MyHomePage({Key key, this.title}) :

    super(key: key); final String title; @override _MyHomePageState createState() => new _MyHomePageState(); }
  6. AppBar class MyHomePage extends StatefulWidget { MyHomePage({Key key, this.title}) :

    super(key: key); final String title; @override _MyHomePageState createState() => new _MyHomePageState(); }
  7. AppBar class _MyHomePageState extends State<MyHomePage> { @override Widget build(BuildContext context)

    { return new Scaffold( appBar: new AppBar( title: new Text(widget.title), ), body: new Center(), ); } }
  8. TabBarView return new DefaultTabController( length: 2, child: new Scaffold( appBar:

    new AppBar( title: new Text(widget.title), bottom: new TabBar( tabs: <Widget>[ new Tab(text: "愛工大ゆき"), new Tab(text: "八草駅ゆき"), ], ), ), body: new TabBarView( children: _pages, ))); } }
  9. TabBarView return new DefaultTabController( length: 2, child: new Scaffold( appBar:

    new AppBar( title: new Text(widget.title), bottom: new TabBar( tabs: <Widget>[ new Tab(text: "愛工大ゆき"), new Tab(text: "八草駅ゆき"), ], ), ), body: new TabBarView( children: _pages, ))); } }
  10. TabBarView return new DefaultTabController( length: 2, child: new Scaffold( appBar:

    new AppBar( title: new Text(widget.title), bottom: new TabBar( tabs: <Widget>[ new Tab(text: "愛工大ゆき"), new Tab(text: "八草駅ゆき"), ], ), ), body: new TabBarView( children: _pages, ))); } }
  11. TabBarView return new DefaultTabController( length: 2, child: new Scaffold( appBar:

    new AppBar( title: new Text(widget.title), bottom: new TabBar( tabs: <Widget>[ new Tab(text: "愛工大ゆき"), new Tab(text: "八草駅ゆき"), ], ), ), body: new TabBarView( children: _pages, ))); } }
  12. TabBarView final List<Widget> _pages = <Widget>[ Column( children: <Widget>[ Padding(

    padding: const EdgeInsets.all(32.0), child: new Text("widget1"), ) ], ), Column( children: <Widget>[ Padding( padding: const EdgeInsets.all(32.0), child: new Text("widget2"), ) ], ), ];
  13. CustomTabBar class CustomTabBar extends StatelessWidget implements PreferredSizeWidget { final TabBar

    tabBar; final String currentDate; final String currentTimeTable; CustomTabBar({ this.currentDate, this.currentTimeTable, this.tabBar }) : super();
  14. CustomTabBar class CustomTabBar extends StatelessWidget implements PreferredSizeWidget { final TabBar

    tabBar; final String currentDate; final String currentTimeTable; CustomTabBar({ this.currentDate, this.currentTimeTable, this.tabBar }) : super();
  15. CustomTabBar class CustomTabBar extends StatelessWidget implements PreferredSizeWidget { final TabBar

    tabBar; final String currentDate; final String currentTimeTable; CustomTabBar({ this.currentDate, this.currentTimeTable, this.tabBar }) : super();
  16. CustomTabBar class CustomTabBar extends StatelessWidget implements PreferredSizeWidget { final TabBar

    tabBar; final String currentDate; final String currentTimeTable; CustomTabBar({ this.currentDate, this.currentTimeTable, this.tabBar }) : super();
  17. CustomTabBar @override Size get preferredSize => new Size(0.0, 90.0); @override

    Widget build(BuildContext context) { return new Column( children: <Widget>[ createCurrentStatus(), tabBar ], ); }
  18. CustomTabBar @override Size get preferredSize => new Size(0.0, 90.0); @override

    Widget build(BuildContext context) { return new Column( children: <Widget>[ createCurrentStatus(), tabBar ], ); }
  19. CustomTabBar @override Size get preferredSize => new Size(0.0, 90.0); @override

    Widget build(BuildContext context) { return new Column( children: <Widget>[ createCurrentStatus(), tabBar ], ); }
  20. CustomTabBar @override Size get preferredSize => new Size(0.0, 90.0); @override

    Widget build(BuildContext context) { return new Column( children: <Widget>[ createCurrentStatus(), tabBar ], ); }
  21. CustomTabBar Widget createCurrentStatus() { return Row( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[

    createExpanded(currentDate), createExpanded(currentTimeTable), ], ); } Widget A (currentDate) Widget B (currentTimeTable)
  22. CustomTabBar Expanded createExpanded(String text) { return new Expanded( flex: 1,

    child: new Container( decoration: new BoxDecoration( border: new Border.all(color: Colors.white) ), child: ...
  23. CustomTabBar Expanded createExpanded(String text) { return new Expanded( flex: 1,

    child: new Container( decoration: new BoxDecoration( border: new Border.all(color: Colors.white) ), child: ...
  24. CustomTabBar Expanded createExpanded(String text) { return new Expanded( flex: 1,

    child: new Container( decoration: new BoxDecoration( border: new Border.all(color: Colors.white) ), child: ...
  25. CustomTabBar child: new Padding( padding: const EdgeInsets.all(2.0), child: new MaterialButton(

    onPressed: () {}, child: new Text( text, style: new TextStyle( color: Colors.white ), ), ), ), ), ); }
  26. CustomTabBar child: new Scaffold( appBar: new AppBar( title: new Text(widget.title),

    bottom: new CustomTabBar( currentDate: "2018年4月16日(月)", currentTimeTable: "Aダイヤ", tabBar: new TabBar( tabs: <Widget>[ new Tab(text: "愛工大ゆき"), new Tab(text: "八草駅ゆき"), ], ), ), ),
  27. CustomTabBar child: new Scaffold( appBar: new AppBar( title: new Text(widget.title),

    bottom: new CustomTabBar( currentDate: "2018年4月16日(月)", currentTimeTable: "Aダイヤ", tabBar: new TabBar( tabs: <Widget>[ new Tab(text: "愛工大ゆき"), new Tab(text: "八草駅ゆき"), ], ), ), ),
  28. CustomTabBar child: new Scaffold( appBar: new AppBar( title: new Text(widget.title),

    bottom: new CustomTabBar( currentDate: "2018年4月16日(月)", currentTimeTable: "Aダイヤ", tabBar: new TabBar( tabs: <Widget>[ new Tab(text: "愛工大ゆき"), new Tab(text: "八草駅ゆき"), ], ), ), ),
  29. CustomTabBar child: new Scaffold( appBar: new AppBar( title: new Text(widget.title),

    bottom: new CustomTabBar( currentDate: "2018年4月16日(月)", currentTimeTable: "Aダイヤ", tabBar: new TabBar( tabs: <Widget>[ new Tab(text: "愛工大ゆき"), new Tab(text: "八草駅ゆき"), ], ), ), ),
  30. ListView static List<String> createDataList() { List<String> list = List(); for

    (int i = 0; i < 100; i++) { list.add("test$i"); } return list; }
  31. ListView static List<String> createDataList() { List<String> list = List(); for

    (int i = 0; i < 100; i++) { list.add("test$i"); } return list; }
  32. ListView static List<Card> createCards(List<String> list) { List<Card> cardList = new

    List(); list.forEach((s) { cardList.add(new Card( child: Padding( padding: const EdgeInsets.all(16.0), child: Text(s), ))); }); return cardList; }
  33. ListView static List<Card> createCards(List<String> list) { List<Card> cardList = new

    List(); list.forEach((s) { cardList.add(new Card( child: Padding( padding: const EdgeInsets.all(16.0), child: Text(s), ))); }); return cardList; }
  34. ListView static ListView createListView() { return new ListView( shrinkWrap: true,

    padding: const EdgeInsets.all(20.0), children: createCards(createDataList()), ); }
  35. ListView static ListView createListView() { return new ListView( shrinkWrap: true,

    padding: const EdgeInsets.all(20.0), children: createCards(createDataList()), ); }
  36. http.getで取ってくる Future<Destinations> fetchPost() async { final response = await http.get(

    'http://api.syarihu.net/ait_timetable/timetables/'); final responseJson = json.decode(response.body); return new Destinations.fromJson(responseJson); }
  37. http.getで取ってくる Future<Destinations> fetchPost() async { final response = await http.get(

    'http://api.syarihu.net/ait_timetable/timetables/'); final responseJson = json.decode(response.body); return new Destinations.fromJson(responseJson); }
  38. http.getで取ってくる Future<Destinations> fetchPost() async { final response = await http.get(

    'http://api.syarihu.net/ait_timetable/timetables/'); final responseJson = json.decode(response.body); return new Destinations.fromJson(responseJson); }
  39. 結果をWidgetに反映 static FutureBuilder<Destinations> createFutureBuilder( int destination) { return new FutureBuilder<Destinations>(

    future: fetchPost(), builder: (context, snapshot) { if (snapshot.hasData) { return createListView( snapshot.data.destinations[destination].timetables); } else if (snapshot.hasError) { return new Text("${snapshot.error}"); } return new CircularProgressIndicator(); }, ); }
  40. 結果をWidgetに反映 static FutureBuilder<Destinations> createFutureBuilder( int destination) { return new FutureBuilder<Destinations>(

    future: fetchPost(), builder: (context, snapshot) { if (snapshot.hasData) { return createListView( snapshot.data.destinations[destination].timetables); } else if (snapshot.hasError) { return new Text("${snapshot.error}"); } return new CircularProgressIndicator(); }, ); }
  41. 結果をWidgetに反映 static FutureBuilder<Destinations> createFutureBuilder( int destination) { return new FutureBuilder<Destinations>(

    future: fetchPost(), builder: (context, snapshot) { if (snapshot.hasData) { return createListView( snapshot.data.destinations[destination].timetables); } else if (snapshot.hasError) { return new Text("${snapshot.error}"); } return new CircularProgressIndicator(); }, ); }
  42. 結果をWidgetに反映 static FutureBuilder<Destinations> createFutureBuilder( int destination) { return new FutureBuilder<Destinations>(

    future: fetchPost(), builder: (context, snapshot) { if (snapshot.hasData) { return createListView( snapshot.data.destinations[destination].timetables); } else if (snapshot.hasError) { return new Text("${snapshot.error}"); } return new CircularProgressIndicator(); }, ); }
  43. 結果をWidgetに反映 static FutureBuilder<Destinations> createFutureBuilder( int destination) { return new FutureBuilder<Destinations>(

    future: fetchPost(), builder: (context, snapshot) { if (snapshot.hasData) { return createListView( snapshot.data.destinations[destination].timetables); } else if (snapshot.hasError) { return new Text("${snapshot.error}"); } return new CircularProgressIndicator(); }, ); }
  44. 結果をWidgetに反映 class _MyHomePageState extends State<MyHomePage> { final List<Widget> _pages =

    <Widget>[ new ConstrainedBox( constraints: const BoxConstraints.expand(), child: createFutureBuilder(0), ), new ConstrainedBox( constraints: const BoxConstraints.expand(), child: createFutureBuilder(1), ), ];
  45. 結果をWidgetに反映 class _MyHomePageState extends State<MyHomePage> { final List<Widget> _pages =

    <Widget>[ new ConstrainedBox( constraints: const BoxConstraints.expand(), child: createFutureBuilder(0), ), new ConstrainedBox( constraints: const BoxConstraints.expand(), child: createFutureBuilder(1), ), ];
  46. NOW & FUTURE TechBooster • Android • Flutter • Swift

    • Kotlin のコルーチン の動作原理など モバイル技術に注目した 解説書です