Save 37% off PRO during our Black Friday Sale! »

中規模プロダクトにFlutterを採用する

 中規模プロダクトにFlutterを採用する

Df7d212b0cf922e1ef5d16765d3fac56?s=128

Naoto Horiguchi

July 16, 2019
Tweet

Transcript

  1. Flutter Meetup Tokyo #10 தن໛ϓϩμΫτͰFlutterΛ࠾༻͢ Δ LINEגࣜձࣾ ງޱ௚ਓ@naonya3

  2. ࣗݾ঺հ ງޱ௚ਓ@naonya3 • iOS։ൃ7೥΄Ͳ • Flutter 3ϲ݄΄Ͳ • LINEͰಇ͍͍ͯ·͢

  3. ຊ೔఻͍͑ͨ͜ͱ • Flutter͸ϓϩμΫτʹ࠾༻Ͱ͖Δ

  4. ࿩͢಺༰ • ͳͥ࠾༻͢Δؾʹͳͬͨͷ͔ • தن໛ϓϩμΫτ͕৐Γӽ͑Δ΂͖՝୊ • Tips

  5. ͳͥ࠾༻͢Δؾʹͳͬͨͷ͔ • ॳظʹΞαΠϯͰ͖ΔΞϓϦΤϯδχΞ͕֤OS̍ਓ͍ͮͭͨ • ։ൃظؒ͸͋·Γ༨༟͕ͳ͍ • ࢓༷Fix·Ͱʹ͕࣌ؒ͋Γٕज़ݕূͷ͕࣌ؒͱΕͨ • PlatformView͕Α͘ಈ͍ͨ

  6. PlatformViewͱ͸ • NativeͰ࣮૷ͨ͠ViewΛFlutterͷWidgetͱͯ͠ඳը͢Δػೳ • Flutter͚ͩͰ࣮ݱ͕೉͍͠ػೳΛ࣮૷͢ΔͨΊ

  7. FlutterͰNativeͷػೳΛ࢖͍͍ͨ৔ ߹ • PlatformView • Nativeͷը໘ΛFlutterͷWidgetͱͯ͠ը໘ʹඳըͰ͖Δػೳ • MethodChannel • Flutter-NativeؒͰػೳͷݺͼग़͠ͱσʔλͷ΍ΓऔΓ͕Ͱ͖Δ

    • EventChannel • ҰํతʹσʔλΛ౤͚͛ͭͮͦΕΛߪಡ͢ΔɻStream
  8. தن໛ϓϩμΫτ͕৐Γӽ͑Δ΂͖՝ ୊ • ଞSDKͱͷ࿈ܞ • LINE SDK • ಺੡αʔϏεͱͷ࿈ܞ •

    ͓஌Βͤ഑৴αʔϏε • ଟݴޠԽ • ࣾ಺ͷ຋༁γεςϜͱͷ࿈ܞ
  9. LINE SDK • LINEͷAPIΛୟͨ͘Ίʹ༻ҙ͞Ε͍ͯΔSDK • ओʹLINEϩάΠϯ

  10. LINE SDK • LINE SDK for iOS • LINE SDK

    for Android • LINE SDK for Unity • LINE SDK for Flutter • https:/ /pub.dev/packages/flutter_line_sdk
  11. pubspec.yaml dependencies flutter_line_sdk: ^1.0.1

  12. main.dart import 'package:flutter_line_sdk/flutter_line_sdk.dart'; // Setup void main() { LineSDK.instance.setup("{CHANNEL ID}").then((_)

    { print("LineSDK Prepared"); // login(); }); runApp(App()); } // Login void login() async { try { final result = await LineSDK.instance.login(); print(result.userProfile.displayName); } on PlatformException catch (e) { // Error handling. print(e); } }
  13. ଞSDKΛFlutter͔Βར༻͢Δํ๏ • MethodChannelͰϥοϓ͢Δ • Flutter <- MethodChannel -> SDK

  14. ͓஌Βͤ഑৴αʔϏεͱͷ࿈ܞ • ؅ཧը໘͔Β͓஌ΒͤΛొ࿥ • ΞϓϦىಈ࣌ʹpopupΛදࣔͰ͖Δ • FlutterSDK͸ఏڙ͞Ε͍ͯͳ͍ • ࣗ෼ͨͪͰDartͰ࣮૷ͨ͠ •

    ࣾ಺΁ͷެ։΍υΩϡϝϯτ੔උͳͲͰFlutterΛࣾ಺͔Β΋੝ Γ্͍͖͍͛ͯͨ !
  15. ଟݴޠԽ • ଟݴޠԽࣗମʹ͸intlΛར༻͍ͯ͠Δ • ࣾ಺ͷ຋༁ϑϩʔʹ߹ΘͤΔඞཁ͕͋ͬͨ

  16. ଟݴޠԽͷϑϩʔ • keyΛఆٛͯࣾ͠಺ͷ຋༁γεςϜʹొ࿥ • ຋༁ऀ͸຋༁Λ຋༁γεςϜʹొ࿥ • ։ൃऀ͸຋༁͞ΕͨϑΝΠϧΛγεςϜ͔Βμ΢ϯϩʔυ • ରԠܗࣜ͸ strings.xml

    / .stringsɹͳͲ • intl͸ARBʹରԠ͍ͯ͠Δ
  17. .strings to ARB .string hello.text=͜Μʹͪ͸ʂ{lastName} {firstName}

  18. .strings to ARB ARB { "@@locale": "ja", "@@last_modified": "2019-07-09T14:53:30.474639", "helloText":

    "͜Μʹͪ͸ʂ{lastName} {firstName}", "@helloText": { "type": "text", "placeholders": { "lastName": {}, "firstName": {} } } }
  19. Tips • gRPC • intl

  20. gRPC • packageʹ·ͱΊΔ • submoduleΛߋ৽ͯ͠push • drone͕hookͯ͠build pubspec.yaml my_grpc_package: git:

    url: git@example.com:my_grpc_package.git
  21. intl 1.ॻ͘ String helloText(String lastName, String firstName) => Intl.message( '͜Μʹͪ͸ʂ${lastName}

    ${firstName}', name: 'helloText', args: [lastName, firstName], ); 2.ARBΛੜ੒ 3.ARBΛ຋༁ʹ·Θ͢ 4.ARB͔ΒଟݴޠԽ༻ͷίʔυΛੜ੒
  22. ਤղฐࣾͷଟݴޠԽϑϩʔ

  23. ࣗಈੜ੒͞ΕΔίʔυ Message.dart import 'package:intl/intl.dart'; class Messages { String helloText(String lastName,

    String firstName) => Intl.message( '͜Μʹͪ͸ʂ${lastName} ${firstName}', name: 'helloText', args: [lastName, firstName], ); }
  24. MixinͰศར ... import 'messages.dart'; class L10n with Messages { static

    L10n of(BuildContext context) { return Localizations.of<L10n>(context, L10n); } ...
  25. ·ͱΊ ࢲͨͪ͸ϓϩμΫτʹ౤ೖ͍͖ͯ͠·͢

  26. એ఻ ! • LINE SDK ͸ͪ͜Β • https:/ /pub.dev/packages/flutter_line_sdk •

    https:/ /developers.line.biz/ja/docs/flutter-sdk/ • ϦϑΝϥϧ࠾༻ΛڧԽ͍ͯ͠·͢ • ΋͠LINEʹڵຯ͕͋Γ·ͨ͠Β͓ؾܰʹͲ͏ͧ