{"id":1248,"date":"2021-05-18T00:47:43","date_gmt":"2021-05-17T15:47:43","guid":{"rendered":"http:\/\/blog.box.kr\/?p=1248"},"modified":"2021-05-18T00:47:47","modified_gmt":"2021-05-17T15:47:47","slug":"%ec%95%b1-%ec%83%81%ed%83%9capplifecycle-%ec%9d%b4%eb%b2%a4%ed%8a%b8-%ec%96%bb%ea%b8%b0","status":"publish","type":"post","link":"https:\/\/blog.box.kr\/?p=1248","title":{"rendered":"\uc571 \uc0c1\ud0dc(AppLifeCycle) \uc774\ubca4\ud2b8 \uc5bb\uae30"},"content":{"rendered":"\n<p><a href=\"https:\/\/flutter.dev\/docs\/get-started\/flutter-for\/android-devs#how-do-i-listen-to-android-activity-lifecycle-events\">https:\/\/flutter.dev\/docs\/get-started\/flutter-for\/android-devs#how-do-i-listen-to-android-activity-lifecycle-events<\/a><br><br>\uc774 plugIn\uc744 \uc0ac\uc6a9\ud55c\ub2e4. <br><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import 'package:flutter\/material.dart';\r\n\r\nvoid main() {\r\n  runApp(MyApp());\r\n}\r\n\r\nclass MyApp extends StatelessWidget {\r\n  @override\r\n  Widget build(BuildContext context) {\r\n    return MaterialApp(\r\n      title: 'Flutter Demo',\r\n      theme: ThemeData(\r\n        primarySwatch: Colors.blue,\r\n        visualDensity: VisualDensity.adaptivePlatformDensity,\r\n      ),\r\n      home: MyHomePage(title: 'Flutter Demo Home Page'),\r\n    );\r\n  }\r\n}\r\n\r\nclass MyHomePage extends StatefulWidget {\r\n  MyHomePage({Key key, this.title}) : super(key: key);\r\n  final String title;\r\n\r\n  @override\r\n  _MyHomePageState createState() => _MyHomePageState();\r\n}\r\n\r\n\/\/\uc571 \uc0c1\ud0dc \ubcc0\uacbd \uc774\ubca4\ud2b8\ub97c \ubc1b\uae30 \uc704\ud574 WidgetBindingObserver\ub97c mixin(with) \ud55c\ub2e4.\r\nclass _MyHomePageState extends State&lt;MyHomePage> with WidgetsBindingObserver {\r\n  \r\n  @override\r\n  void initState() {\r\n    \/\/\uc571 \uc0c1\ud0dc \ubcc0\uacbd \uc774\ubca4\ud2b8 \ub4f1\ub85d\r\n    WidgetsBinding.instance.addObserver(this);\r\n    super.initState();\r\n  }\r\n\r\n  @override\r\n  void dispose() {\r\n    \/\/\uc571 \uc0c1\ud0dc \ubcc0\uacbd \uc774\ubca4\ud2b8 \ud574\uc81c\r\n    \/\/\ubb38\uc81c\ub294 \uc571 \uc885\ub8cc\uc2dc dispose\ud568\uc218\uac00 \ud638\ucd9c\ub418\uc9c0 \uc54a\uc544 \ud574\ub2f9 \ud568\uc218\ub97c \uc2e4\ud589 \ud560 \uc218\uac00 \uc5c6\ub2e4.\r\n    WidgetsBinding.instance.removeObserver(this);\r\n    super.dispose();\r\n  }\r\n  \r\n  \/\/ \uc571 \uc0c1\ud0dc \ubcc0\uacbd\uc2dc \ud638\ucd9c\r\n  @override\r\n  void didChangeAppLifecycleState(AppLifecycleState state) {\r\n    \/\/https:\/\/api.flutter.dev\/flutter\/dart-ui\/AppLifecycleState-class.html\r\n    switch (state) {\r\n      case AppLifecycleState.resumed:\r\n        \/\/ \uc571\uc774 \ud45c\uc2dc\ub418\uace0 \uc0ac\uc6a9\uc790 \uc785\ub825\uc5d0 \uc751\ub2f5\ud569\ub2c8\ub2e4.\r\n        \/\/ \uc8fc\uc758! \ucd5c\ucd08 \uc571 \uc2e4\ud589\ub54c\ub294 \ud574\ub2f9 \uc774\ubca4\ud2b8\uac00 \ubc1c\uc0dd\ud558\uc9c0 \uc54a\uc2b5\ub2c8\ub2e4.\r\n        print(\"resumed\");\r\n        break;\r\n      case AppLifecycleState.inactive:\r\n        \/\/ \uc571\uc774 \ube44\ud65c\uc131\ud654 \uc0c1\ud0dc\uc774\uace0 \uc0ac\uc6a9\uc790\uc758 \uc785\ub825\uc744 \ubc1b\uc9c0 \uc54a\uc2b5\ub2c8\ub2e4.\r\n        \/\/ ios\uc5d0\uc11c\ub294 \ud3ec \uadf8\ub77c\uc6b4\ub4dc \ube44\ud65c\uc131 \uc0c1\ud0dc\uc5d0\uc11c \uc2e4\ud589\ub418\ub294 \uc571 \ub610\ub294 Flutter \ud638\uc2a4\ud2b8 \ubdf0\uc5d0 \ud574\ub2f9\ud569\ub2c8\ub2e4.\r\n        \/\/ \uc548\ub4dc\ub85c\uc774\ub4dc\uc5d0\uc11c\ub294 \ud654\uba74 \ubd84\ud560 \uc571, \uc804\ud654 \ud1b5\ud654, PIP \uc571, \uc2dc\uc2a4\ud15c \ub300\ud654 \uc0c1\uc790 \ub610\ub294 \ub2e4\ub978 \ucc3d\uacfc \uac19\uc740 \ub2e4\ub978 \ud65c\ub3d9\uc774 \uc9d1\uc911\ub418\uba74 \uc571\uc774\uc774 \uc0c1\ud0dc\ub85c \uc804\ud658\ub429\ub2c8\ub2e4.\r\n        \/\/ inactive\uac00 \ubc1c\uc0dd\ub418\uace0 \uc5bc\ub9c8\ud6c4 pasued\uac00 \ubc1c\uc0dd\ud569\ub2c8\ub2e4.\r\n        print(\"inactive\");\r\n        break;\r\n      case AppLifecycleState.paused:\r\n        \/\/ \uc571\uc774 \ud604\uc7ac \uc0ac\uc6a9\uc790\uc5d0\uac8c \ubcf4\uc774\uc9c0 \uc54a\uace0, \uc0ac\uc6a9\uc790\uc758 \uc785\ub825\uc744 \ubc1b\uc9c0 \uc54a\uc73c\uba70, \ubc31\uadf8\ub77c\uc6b4\ub4dc\uc5d0\uc11c \ub3d9\uc791 \uc911\uc785\ub2c8\ub2e4.\r\n        \/\/ \uc548\ub4dc\ub85c\uc774\ub4dc\uc758 onPause()\uc640 \ub3d9\uc77c\ud569\ub2c8\ub2e4.\r\n        \/\/ \uc751\uc6a9 \ud504\ub85c\uadf8\ub7a8\uc774 \uc774 \uc0c1\ud0dc\uc5d0 \uc788\uc73c\uba74 \uc5d4\uc9c4\uc740 Window.onBeginFrame \ubc0f Window.onDrawFrame \ucf5c\ubc31\uc744 \ud638\ucd9c\ud558\uc9c0 \uc54a\uc2b5\ub2c8\ub2e4.\r\n        print(\"paused\");\r\n        break;\r\n      case AppLifecycleState.detached:\r\n        \/\/ \uc751\uc6a9 \ud504\ub85c\uadf8\ub7a8\uc740 \uc5ec\uc804\ud788 flutter \uc5d4\uc9c4\uc5d0\uc11c \ud638\uc2a4\ud305\ub418\uc9c0\ub9cc \"\ud638\uc2a4\ud2b8 View\"\uc5d0\uc11c \ubd84\ub9ac\ub429\ub2c8\ub2e4.\r\n        \/\/ \uc571\uc774 \uc774 \uc0c1\ud0dc\uc5d0 \uc788\uc73c\uba74 \uc5d4\uc9c4\uc774 \"View\"\uc5c6\uc774 \uc2e4\ud589\ub429\ub2c8\ub2e4.\r\n        \/\/ \uc5d4\uc9c4\uc774 \ucc98\uc74c \ucd08\uae30\ud654 \ub420 \ub54c \"View\" \uc5f0\uacb0 \uc9c4\ud589 \uc911\uc774\uac70\ub098 \ub124\ube44\uac8c\uc774\ud130 \ud31d\uc73c\ub85c \uc778\ud574 \"View\"\uac00 \ud30c\uad34 \ub41c \ud6c4 \uc77c \uc218 \uc788\uc2b5\ub2c8\ub2e4.\r\n        print(\"detached\");\r\n        break;\r\n    }\r\n  }\r\n\r\n  @override\r\n  Widget build(BuildContext context) {\r\n    return Scaffold(\r\n      appBar: AppBar(\r\n        title: Text(widget.title),\r\n      ),\r\n      body: Center(child: Text(\"WidgetsBindingObserver Test.\")),\r\n    );\r\n  }\r\n}<\/code><\/pre>\n\n\n\n<p>\uc571 \ud65c\uc131 \ub41c \uc0c1\ud0dc\uc5d0\uc11c back \ud0a4\ub97c \ub20c\ub7ec \uc571\uc744 \uc885\ub8cc\ud558\uba74 inactive > paused > detached \uc21c\uc73c\ub85c \ubc1c\uc0dd\ub418\ub294 \uac83\uc744 \ubcfc \uc218 \uc788\uc5c8\ub2e4. \uc571\uc774 \uc885\ub8cc\ub41c \uc0c1\ud0dc\ub77c\uace0 \ubcf4\uba74 \ub428<br><br>\uc548\ub4dc\ub85c\uc774\ub4dc Native\uc640\ub294 \ub2e4\ub974\uac8c \uc571\uc774 \uc2e4\ud589\ub420\ub54c\ub294 <strong>onResume <\/strong>\uc774\ubca4\ud2b8\uac00 \ubc1c\uc0dd\ud558\uc9c0 \uc54a\ub294\ub2e4.<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>https:\/\/flutter.dev\/docs\/get-started\/flutter-for\/android-devs#how-do-i-listen-to-android-activity-lifecycle-events \uc774 plugIn\uc744 \uc0ac\uc6a9\ud55c\ub2e4. \uc571 \ud65c\uc131 \ub41c \uc0c1\ud0dc\uc5d0\uc11c back \ud0a4\ub97c \ub20c\ub7ec \uc571\uc744 \uc885\ub8cc\ud558\uba74 inactive > paused > detached \uc21c\uc73c\ub85c \ubc1c\uc0dd\ub418\ub294 \uac83\uc744 \ubcfc \uc218 \uc788\uc5c8\ub2e4. \uc571\uc774 \uc885\ub8cc\ub41c \uc0c1\ud0dc\ub77c\uace0 \ubcf4\uba74 \ub428 \uc548\ub4dc\ub85c\uc774\ub4dc Native\uc640\ub294 \ub2e4\ub974\uac8c \uc571\uc774 \uc2e4\ud589\ub420\ub54c\ub294 onResume \uc774\ubca4\ud2b8\uac00 \ubc1c\uc0dd\ud558\uc9c0 \uc54a\ub294\ub2e4.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false,"ngg_post_thumbnail":0,"spay_email":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true},"categories":[41],"tags":[],"aioseo_notices":[],"jetpack_featured_media_url":"","jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p5q9Zn-k8","jetpack-related-posts":[{"id":1257,"url":"https:\/\/blog.box.kr\/?p=1257","url_meta":{"origin":1248,"position":0},"title":"BLE \uc0ac\uc6a9\ud558\uae30","date":"2021-05-18","format":false,"excerpt":"\ub77c\uc774\ube0c\ub7ec\ub9ac \ucd94\uac00 \ubc0f SCAN \uae30\ub2a5 \uad6c\ud604flutter_ble_libhttps:\/\/pub.dev\/packages\/flutter_ble_libpermission_handlerhttps:\/\/pub.dev\/packages\/permission_handler\ud504\ub85c\uc81d\ud2b8\uc5d0 \uc548\ub4dc\ub85c\uc774\ub4dc SDK \ubc84\uc804\uc774 \ub0ae\uac8c \uc124\uc815\ub418\uc5b4 \uc544\ub798\uc640 \uac19\uc740 \uc5d0\ub7ec\uac00 \ubc1c\uc0dd\ud560 \uc218\uc774\ub2e4 ble_example\\android\\app\\src\\debug\\AndroidManifest.xml Error: uses-sdk:minSdkVersion 16 cannot be smaller than version 18 declared in library [:flutter_ble_lib] E:\\study\\flutter\\ble_example\\build\\flutter_ble_lib\\intermediates\\library_manifest\\debug\\AndroidManifest.xml as the library might be using APIs not available in 16 Suggestion: use a compatible library with a minSdk\u2026","rel":"","context":"In &quot;flutter&quot;","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/blog.box.kr\/wp-content\/uploads\/2021\/05\/image.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":1254,"url":"https:\/\/blog.box.kr\/?p=1254","url_meta":{"origin":1248,"position":1},"title":"\uc571 \ud654\uba74 \ud06c\uae30 \uc54c\uc544\ub0b4\uae30(App Screen Size)","date":"2021-05-18","format":false,"excerpt":"Js\ucc98\ub7fc.. MediaQuery \ub77c\ub294\uac78 \uc0ac\uc6a9\ud55c\ub2e4. MediaQuery.of(context).size \/\/\uc571 \ud654\uba74 \ud06c\uae30 size Ex> Size(360.0, 692.0) MediaQuery.of(context).size.height \/\/\uc571 \ud654\uba74 \ub192\uc774 double Ex> 692.0 MediaQuery.of(context).size.width \/\/\uc571 \ud654\uba74 \ub113\uc774 double Ex> 360.0 MediaQuery.of(context).devicePixelRatio \/\/\ud654\uba74 \ubc30\uc728 double Ex> 4.0 MediaQuery.of(context).padding.top \/\/\uc0c1\ub2e8 \uc0c1\ud0dc \ud45c\uc2dc\uc904 \ub192\uc774 double Ex> 24.0 \uc704\uc758 \uac12\ub4e4\uc740 \uc2e4\uc81c \ud53d\uc140 \uac12\uc774 \uc544\ub2cc \ub17c\ub9ac\uc801 \ud53d\uc140 \uac12\uc774\ub2e4. \uc5ec\uae30\uc5d0\u2026","rel":"","context":"In &quot;flutter&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1266,"url":"https:\/\/blog.box.kr\/?p=1266","url_meta":{"origin":1248,"position":2},"title":"QR \ucf54\ub4dc \uc2a4\uce94(QR Code Scan) \ucd08\uac04\ub2e8 \uc608\uc81c(Simple example)","date":"2021-05-18","format":false,"excerpt":"https:\/\/pub.dev\/packages \uc5d0\uc11c qrscan \uac80\uc0c9 AndroidManifest.xml \ud37c\ubbf8\uc158 \ucd94\uac00 \uc704\uce58 : project\/android\/app\/src\/main\/AndroidManifext.xml \uc548\ub4dc\ub85c\uc774\ub4dc\uc758 \uce74\uba54\ub77c\uc640 \uc800\uc7a5\uc18c \uc81c\uc5b4\ub97c \uc704\ud55c \ud37c\ubbf8\uc158\uc744 \ucd94\uac00\ud574 \uc900\ub2e4. \uc2e4\uc81c \uc6b0\ub9ac\uac00 \ud14c\uc2a4\ud2b8\ud558\ub294 \ucf54\ub4dc\uc5d0\ub294 \uad73\uc774 \uc800\uc7a5\uc18c \uad00\ub828\uc740 \ud544\uc694 \uc5c6\uc9c0\ub9cc qrscan \ud328\ud0a4\uc9c0 \ub0b4\uc5d0\uc11c \ubaa8\ub450 \uc0ac\uc6a9\ud558\ub2c8 \uc5b4\uca54 \uc218 \uc5c6\ub2e4. <uses-permission android:name=\"android.permission.CAMERA\" \/> <uses-permission android:name=\"android.permission.WRITE_EXTERNAL_STORAGE\"\/> <uses-permission android:name=\"android.permission.READ_EXTERNAL_STORAGE\"\/> import 'dart:async'; import 'package:flutter\/material.dart'; import 'package:qrscan\/qrscan.dart' as scanner;\u2026","rel":"","context":"In &quot;flutter&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1239,"url":"https:\/\/blog.box.kr\/?p=1239","url_meta":{"origin":1248,"position":3},"title":"Flutter \uc0ac\uc6a9 \uc815\ub9ac","date":"2021-05-14","format":false,"excerpt":"OSX, Windows, Linux, Web\uc5d0\uc11c \uc0ac\uc6a9\ud558\uae30 \uc704\ud574\uc11c\ub294 \uac01 \uae30\ub2a5\uc744 \ucf1c\uc918\uc57c\ud568. Flutter\ub85c \ub370\uc2a4\ud06c\ud1b1 \uc560\ud50c\ub9ac\ucf00\uc774\uc158 \uac1c\ubc1c \uc2dc\uc791\ud558\uae30 \uc77c\ud68c\uc131 \uad6c\uc131 \ubcc0\uacbd\uc73c\ub85c \ub370\uc2a4\ud06c\ud1b1 \uc9c0\uc6d0\uc744 \uad6c\uc131\ud574\uc57c\ud569\ub2c8\ub2e4.$ flutter config --enable-windows-desktop # for the Windows runner$ flutter config --enable-macos-desktop \u00a0 # for the macOS runner$ flutter config --enable-linux-desktop \u00a0 # for the Linux runner \ub370\uc2a4\ud06c\ud1b1 \uc6a9 Flutter\uac00 \ud65c\uc131\ud654\ub418\uc5c8\ub294\uc9c0\u2026","rel":"","context":"In &quot;flutter&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1252,"url":"https:\/\/blog.box.kr\/?p=1252","url_meta":{"origin":1248,"position":4},"title":"Back Button \ub9c9\uae30(Disable Back Button)","date":"2021-05-18","format":false,"excerpt":"WillPopScope \uc704\uc82f\uc744 \uc0ac\uc6a9\ud55c\ub2e4. scaffold\ub97c WillPopScope\ub85c \uac10\uc2f8\uc11c \ucc98\ub9ac \ud55c\ub2e4. return Scaffold( appBar: AppBar( title: Text('demo page1'), leading: \/\/<- leading \ud56d\ubaa9\uc744 \uc9c1\uc811 \ucd94\uac00 IconButton( icon: Icon(Icons.arrow_back), \/\/ <- \uc544\uc774\ucf58\ub3c4 \ub3d9\uc77c\ud55c \uac83\uc744 \uc0ac\uc6a9 onPressed: () { Navigator.pop(context); \/\/ <- \uc774\uc804 \ud398\uc774\uc9c0\ub85c \uc774\ub3d9. }, ), ), body: WillPopScope( onWillPop: () { return Future(() =>\u2026","rel":"","context":"In &quot;flutter&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1250,"url":"https:\/\/blog.box.kr\/?p=1250","url_meta":{"origin":1248,"position":5},"title":"\ud328\ud0a4\uc9c0(Package) \uc218\uc815\ud558\uae30","date":"2021-05-18","format":false,"excerpt":"Github\uc5d0\uc11c \uace0\uce60 Package\ub97c Fork \ud55c \ud6c4\uc5d0 \ud574\ub2f9 \uc18c\uc2a4\ub97c \uace0\uce58\uace0 Github\uc5d0 commit \/ push \ud574\uc11c \uc0ac\uc6a9\ud568pubspec.yaml\uc5d0 \uc544\ub798\uc640 \uac19\uc774 \uae30\uc785#qrscan: ^0.2.17 # \uae30\uc874\uc5d0 \uc788\ub358 \ud328\ud0a4\uc9c0\ub294 \uc8fc\uc11d \ub610\ub294 \uc0ad\uc81c plugin_test: git: url: https:\/\/github.com\/chandong83\/qrcode_scanner.git ref: master \uc704\uc640 \uac19\uc774 \ucc98\ub9ac \ud558\uace0 \ubc18\ub4dc\uc2dc .. flutter pub upgrade \ucc98\ub9ac \ud574\uc11c update\ud574\uc918\uc57c \ubcc0\uacbd\ub428\ub0b4\ubd80\uc5d0 \ud654\uc77c\uc744 \ub0b4\ub824 \ubc1b\uc544\uc11c \ubc14\ub85c\ubc14\ub85c \uc0ac\uc6a9\ud558\uae30\u2026","rel":"","context":"In &quot;flutter&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"https:\/\/blog.box.kr\/index.php?rest_route=\/wp\/v2\/posts\/1248"}],"collection":[{"href":"https:\/\/blog.box.kr\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.box.kr\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.box.kr\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.box.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1248"}],"version-history":[{"count":1,"href":"https:\/\/blog.box.kr\/index.php?rest_route=\/wp\/v2\/posts\/1248\/revisions"}],"predecessor-version":[{"id":1249,"href":"https:\/\/blog.box.kr\/index.php?rest_route=\/wp\/v2\/posts\/1248\/revisions\/1249"}],"wp:attachment":[{"href":"https:\/\/blog.box.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1248"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.box.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1248"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.box.kr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1248"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}