{"id":567,"date":"2019-10-22T21:12:32","date_gmt":"2019-10-22T12:12:32","guid":{"rendered":"http:\/\/www.typea.info\/blog\/index.php\/2019\/10\/22\/flutter_2\/"},"modified":"2020-04-27T23:03:08","modified_gmt":"2020-04-27T14:03:08","slug":"flutter_2","status":"publish","type":"post","link":"https:\/\/www.typea.info\/blog\/index.php\/2019\/10\/22\/flutter_2\/","title":{"rendered":"Flutter : \u753b\u50cf\u306e\u5207\u308a\u629c\u304d"},"content":{"rendered":"<p>Flutter + Firebase \u3067\u30a2\u30d7\u30ea\u4f5c\u6210\u306e\u305f\u3081\u306e\u30d1\u30fc\u30c4\u3042\u3064\u3081\u3002<\/p>\n<ul>\n<li><a href=\"https:\/\/www.typea.info\/blog\/index.php\/2019\/10\/03\/xamarin_flutter\">Flutter+Firebase\u74b0\u5883\u8a2d\u5b9a<\/a><\/li>\n<li><a href=\"https:\/\/www.typea.info\/blog\/index.php\/2019\/10\/03\/flutter\">\u753b\u9762\u9077\u79fb<\/a><\/li>\n<li><a href=\"https:\/\/www.typea.info\/blog\/index.php\/2019\/10\/03\/flutter_dialog\">Dialog<\/a><\/li>\n<li><a href=\"https:\/\/www.typea.info\/blog\/index.php\/2019\/10\/03\/flutter_httpclient\">Http\u30af\u30e9\u30a4\u30a2\u30f3\u30c8<\/a><\/li>\n<li><a href=\"https:\/\/www.typea.info\/blog\/index.php\/2019\/10\/21\/flutter_androidx\">AndroidX\u5bfe\u5fdc<\/a><\/li>\n<li><a href=\"https:\/\/www.typea.info\/blog\/index.php\/2019\/10\/21\/flutter_1\">\u753b\u50cf\u306e\u9078\u629e<\/a><\/li>\n<\/ul>\n<p>\u307e\u3067\u3001Android\u3001iOS\u3067\u306e\u7c21\u6613\u52d5\u4f5c\u78ba\u8a8d\u304c\u3067\u304d\u305f\u306e\u3067\u3001\u753b\u50cf\u5207\u308a\u629c\u304d\u30d1\u30c3\u30b1\u30fc\u30b8\u3001<a href=\"https:\/\/pub.dev\/packages\/image_cropper\">image_cropper<\/a> \u3092\u8a66\u3059\u3002<\/p>\n<h2>1.\u4f8b\u306b\u3088\u3063\u3066\u30a8\u30e9\u30fc\u5bfe\u5fdc<\/h2>\n<p><a href=\"https:\/\/pub.dev\/packages\/image_cropper\">pub.dev\u306eimage_cropper<\/a>\u30da\u30fc\u30b8\u306eExample\u306b\u5f93\u3044\u3001\u30b3\u30fc\u30c9\u3092\u8a18\u8ff0\u3057\u5b9f\u884c\u3059\u308b\u304c\u3001androidx.core.widget.TintableCompoundDrawableView \u304c\u5b58\u5728\u3057\u306a\u3044\u30a8\u30e9\u30fc<\/p>\n<pre class=\"prettyprint linenums\">I\/pea.favo_phras( 6224): Rejecting re-init on previously-failed class java.lang.Class<androidx.appcompat.widget.appcompattextview>: java.lang.NoClassDefFoundError: Failed resolution of: Landroidx\/core\/widget\/TintableCompoundDrawablesView;\nI\/pea.favo_phras( 6224):   at java.lang.Object java.lang.Class.newInstance() (Class.java:-2)\nI\/pea.favo_phras( 6224):   at android.app.Activity android.app.AppComponentFactory.instantiateActivity(java.lang.ClassLoader, java.lang.String, android.content.Intent) (AppComponentFactory.java:69)\nI\/pea.favo_phras( 6224):   at android.app.Activity androidx.core.app.CoreComponentFactory.instantiateActivity(java.lang.ClassLoader, java.lang.String, android.content.Intent) (CoreComponentFactory.java:43)<\/androidx.appcompat.widget.appcompattextview><\/pre>\n<p><a href=\"https:\/\/pub.dev\/packages\/image_cropper\">image_cropper<\/a> \u306eGithub\u306eissue\u306b\u540c\u3058\u4e8b\u8c61\u306e\u5831\u544a\u304a\u3088\u3073\u89e3\u6c7a\u7b56\u60c5\u5831\u3042\u308a\u3002<\/p>\n<p><a href=\"https:\/\/github.com\/hnvn\/flutter_image_cropper\/issues\/78\">https:\/\/github.com\/hnvn\/flutter_image_cropper\/issues\/78<\/a><\/p>\n<p>build.gradle \u306e dependencies \u306b\u4ee5\u4e0b\u3092\u8ffd\u8a18<\/p>\n<p>implementation &#8216;androidx.core:core:1.0.2&#8217;<br \/>\nimplementation &#8216;androidx.appcompat:appcompat:1.0.2&#8217;<\/p>\n<p>\u3068\u306e\u3053\u3068\u3060\u304c\u3001\u305d\u308c\u3060\u3051\u3067\u306f\u89e3\u6c7a\u3057\u306a\u3044\u305f\u3081\u3001\u30a8\u30e9\u30fc\u30ed\u30b0\u3092\u898b\u306a\u304c\u3089\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u8abf\u6574\u3002<\/p>\n<p>Andro<a href=\"https:\/\/www.typea.info\/blog\/index.php\/2019\/10\/21\/flutter_androidx\">AndroidX\u306e\u4e92\u63db\u6027\u5bfe\u5fdc\u3067\u3001\u3053\u306e\u624b\u306e\u30a8\u30e9\u30fc\u89e3\u6c7a\u306e\u30b3\u30c4\u304c\u306a\u3093\u3068\u306a\u304f\u3064\u304b\u3081\u3066\u304d\u305f<\/a>\u304c\u3001\u3001\u3001\u82e5\u5e72\u4e0d\u5b89\u3002<\/p>\n<pre class=\"prettyprint linenums\">dependencies {\n    implementation \"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version\"\n    implementation 'com.google.firebase:firebase-analytics:16.0.0'\n    implementation 'androidx.core:core:1.0.0'\n    implementation 'androidx.appcompat:appcompat:1.1.0'\n    testImplementation 'junit:junit:4.12'\n    androidTestImplementation 'com.android.support.test:runner:1.0.2'\n    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'\n}\n\nconfigurations.all {\n    resolutionStrategy.eachDependency { DependencyResolveDetails details -&gt;\n        print(details.requested.group)\n        if (details.requested.group ==~ \/^androidx\\.(core|viewpager|drawlayout|interpolator|fragment|versionedparcelable|appcompat)\/\n        ) {\n            details.useVersion '1.0.0'\n            details.because 'API needs higher versions'\n        }\n        if (details.requested.group == 'androidx.lifecycle'\n            ) {\n            details.useVersion '2.1.0'\n            details.because 'API needs higher versions'\n        }\n    }\n}\n<\/pre>\n<h2>2.Flutter<\/h2>\n<p>\u4e0a\u8a18\u30a8\u30e9\u30fc\u5bfe\u5fdc\u306b\u3088\u3063\u3066\u3001<a href=\"https:\/\/pub.dev\/packages\/image_cropper\">pub.dev\u306eimage_cropper<\/a>\u30da\u30fc\u30b8\u306eExample\u306e\u30b3\u30fc\u30c9\u304c\u52d5\u3044\u305f\u3002<\/p>\n<h3>2.1 pubspec.yaml(\/)<\/h3>\n<p>\u306b\u4ee5\u4e0b\u3092\u8ffd\u8a18<\/p>\n<pre class=\"prettyprint linenums\">dependencies:\n    :\n  image_cropper: ^1.1.0\n<\/pre>\n<h3>2.2 AndroidManifest.xml(\/android\/app\/main\/res)<\/h3>\n<p>\u306b\u4ee5\u4e0b\u306eActivity\u3092\u8ffd\u52a0\u3002<\/p>\n<pre class=\"prettyprint linenums\">&lt;application&gt;\n    &lt;activity\n        android:name=\"com.yalantis.ucrop.UCropActivity\"\n        android:screenOrientation=\"portrait\"\n        android:theme=\"@style\/Theme.AppCompat.Light.NoActionBar\"\/&gt;\n&lt;\/application&gt;\n<\/pre>\n<h3>2.3 \u30bd\u30fc\u30b9\u30b3\u30fc\u30c9<\/h3>\n<pre class=\"prettyprint linenums\">import 'dart:convert';\nimport 'dart:io';\n\nimport 'package:flutter\/material.dart';\nimport 'package:image_cropper\/image_cropper.dart';\nimport 'package:image_picker\/image_picker.dart';\n\nclass SecondRoute extends StatefulWidget {\n  @override\n  State&lt;StatefulWidget&gt; createState() {\n    return _SecondRoute();\n  }\n}\nclass _SecondRoute extends State&lt;SecondRoute&gt;{\n  Image _image = Image.network('https:\/\/flutter.github.io\/assets-for-api-docs\/assets\/widgets\/owl-2.jpg');\n\n  Future _handleImageCrop(BuildContext context) async {\n\n    var imageFile = await ImagePicker.pickImage(source: ImageSource.camera);\n    var croppedFile = await ImageCropper.cropImage(\n        sourcePath: imageFile.path,\n        aspectRatioPresets: [\n          CropAspectRatioPreset.square,\n          CropAspectRatioPreset.ratio3x2,\n          CropAspectRatioPreset.original,\n          CropAspectRatioPreset.ratio4x3,\n          CropAspectRatioPreset.ratio16x9\n        ],\n        androidUiSettings: AndroidUiSettings(\n            toolbarTitle: 'Cropper',\n            toolbarColor: Colors.deepOrange,\n            toolbarWidgetColor: Colors.white,\n            initAspectRatio: CropAspectRatioPreset.original,\n            lockAspectRatio: false),\n        iosUiSettings: IOSUiSettings(\n          minimumAspectRatio: 1.0,\n        )\n    );\n    setState(() {\n      _image = Image.file(croppedFile);\n    });\n  }\n\n  @override\n  Widget build(BuildContext context) {\n    return LayoutBuilder(\n      builder: (BuildContext context, BoxConstraints viewportConstraints) {\n        return SingleChildScrollView(\n          child: ConstrainedBox(\n            constraints: BoxConstraints(\n              minHeight: viewportConstraints.maxHeight,\n            ),\n            child: IntrinsicHeight(\n              child: Column(\n                children: &lt;Widget&gt;[\n                  Container(\n                    \/\/ A fixed-height child.\n                    color: const Color.fromARGB(255, 255, 255, 255),\n                    height: 120.0,\n                  ),\n                  Expanded(\n                    \/\/ A flexible child that will grow to fit the viewport but\n                    \/\/ still be at least as big as necessary to fit its contents.\n                    child: Container(\n                      color: const Color(0xffffffff),\n                      height: 240.0,\n                      constraints: BoxConstraints(\n                          minWidth: viewportConstraints.maxWidth,\n                          minHeight: double.infinity\n                      ),\n                      child: Column(\n                        children: &lt;Widget&gt;[\n                          RaisedButton(\n                            onPressed: () {\n                              _handleImageCrop(context);\n                            },\n                            child: Text('Image Crop'),\n                          ),\n                          RaisedButton(\n                            onPressed: () {\n                              Navigator.pop(context);\n                            },\n                            child: Text('Back'),\n                          ),\n                          _image,\n                        ],\n                      ),\n                    ),\n                  ),\n                ],\n              ),\n            ),\n          ),\n        );\n      },\n    );\n  }\n\n}<\/pre>\n<h2>3.\u5b9f\u884c<\/h2>\n<h3>3.1 Android<\/h3>\n<p>\u300cImage Crop\u300d\u30dc\u30bf\u30f3\u62bc\u4e0b\u3067\u3001_handleImageCrop() \u3092\u547c\u3073\u51fa\u3057\u3001<a href=\"https:\/\/www.typea.info\/blog\/index.php\/2019\/10\/21\/flutter_1\">\u753b\u50cf\u9078\u629e<\/a> \u3092\u7d4c\u7531(\u30ab\u30e1\u30e9\u3092\u8d77\u52d5)\u3057\u3066\u53d6\u5f97\u3057\u305f\u30d5\u30a1\u30a4\u30eb<\/p>\n<p>var imageFile = await ImagePicker.pickImage(source: ImageSource.camera);<\/p>\n<p>\u3092\u3001<\/p>\n<p>var croppedFile = await ImageCropper.cropImage()<\/p>\n<p>\u306b\u5f15\u304d\u6e21\u3059\u3002<\/p>\n<p><a href=\"https:\/\/github.com\/hnvn\/flutter_image_cropper\/issues\/86\"><img loading=\"lazy\" decoding=\"async\" width=\"176\" height=\"372\" title=\"flutter_image_crop01\" style=\"display: inline; background-image: none;\" alt=\"flutter_image_crop01\" src=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/Flutter--_12DBA\/flutter_image_crop01.png\" border=\"0\"><\/a><\/p>\n<p>\u753b\u50cf\u3092\u5207\u308a\u629c\u304f<\/p>\n<p><a href=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/Flutter--_12DBA\/flutter_image_crop02.png\"><img loading=\"lazy\" decoding=\"async\" width=\"176\" height=\"372\" title=\"flutter_image_crop02\" style=\"display: inline; background-image: none;\" alt=\"flutter_image_crop02\" src=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/Flutter--_12DBA\/flutter_image_crop02_thumb.png\" border=\"0\"><\/a><\/p>\n<p>\u7bc4\u56f2\u3092\u9078\u629e\u3057\u3001\u753b\u9762\u53f3\u4e0a\u306e\u30c1\u30a7\u30c3\u30af<\/p>\n<p><a href=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/Flutter--_12DBA\/flutter_image_crop03.png\"><img loading=\"lazy\" decoding=\"async\" width=\"179\" height=\"380\" title=\"flutter_image_crop03\" style=\"display: inline; background-image: none;\" alt=\"flutter_image_crop03\" src=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/Flutter--_12DBA\/flutter_image_crop03_thumb.png\" border=\"0\"><\/a><\/p>\n<p>\u5207\u308a\u629c\u304b\u308c\u305f\u7bc4\u56f2\u3092\u753b\u9762\u306b\u8868\u793a\u3002OK!!<\/p>\n<p><a href=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/Flutter--_12DBA\/flutter_image_crop04.png\"><img loading=\"lazy\" decoding=\"async\" width=\"181\" height=\"384\" title=\"flutter_image_crop04\" style=\"display: inline; background-image: none;\" alt=\"flutter_image_crop04\" src=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/Flutter--_12DBA\/flutter_image_crop04_thumb.png\" border=\"0\"><\/a><\/p>\n<h3>3.2 iOS<\/h3>\n<p>Android\u540c\u69d8\u306e\u3053\u3068\u3092iPhone\u30a8\u30df\u30e5\u30ec\u30fc\u30bf\u30fc\u3067\u3002<\/p>\n<p>\u7279\u306b\u5909\u66f4\u306f\u306a\u3057\u3002<\/p>\n<p>\u30fb\u30fb\u30fb\u30a8\u30df\u30e5\u30ec\u30fc\u30bf\u306e\u305f\u3081\u3001\u30ab\u30e1\u30e9\u8d77\u52d5\u3067\u304d\u306a\u3044\u3088\u3046\u3067\u3001OK\u3067\u30a8\u30e9\u30fc\u306b\u306a\u308b\u306e\u3067\u3001<\/p>\n<p>var imageFile = await ImagePicker.pickImage(source: ImageSource.camera);<\/p>\n<p>\u3092<\/p>\n<p>var imageFile = await ImagePicker.pickImage(source: ImageSource.gallery);<\/p>\n<p>\u306b\u5909\u66f4\u3057\u3066\u78ba\u8a8d<\/p>\n<p><a href=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/Flutter--_12DBA\/flutter_image_crop_ios01.png\"><img loading=\"lazy\" decoding=\"async\" width=\"181\" height=\"361\" title=\"flutter_image_crop_ios01\" style=\"display: inline; background-image: none;\" alt=\"flutter_image_crop_ios01\" src=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/Flutter--_12DBA\/flutter_image_crop_ios01_thumb.png\" border=\"0\"><\/a><\/p>\n<p>Android\u540c\u69d8\u306b\u753b\u50cf\u306e\u5207\u308a\u629c\u304dUI\u304c\u8d77\u52d5\u3002<\/p>\n<p><a href=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/Flutter--_12DBA\/flutter_image_crop_ios02.png\"><img loading=\"lazy\" decoding=\"async\" width=\"183\" height=\"360\" title=\"flutter_image_crop_ios02\" style=\"display: inline; background-image: none;\" alt=\"flutter_image_crop_ios02\" src=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/Flutter--_12DBA\/flutter_image_crop_ios02_thumb.png\" border=\"0\"><\/a><\/p>\n<p>Done\u3067\u3001\u9078\u629e\u90e8\u5206\u304c\u753b\u9762\u8868\u793a\u3055\u308c\u305f\uff01<\/p>\n<p><a href=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/Flutter--_12DBA\/flutter_image_crop_ios03.png\"><img loading=\"lazy\" decoding=\"async\" width=\"184\" height=\"352\" title=\"flutter_image_crop_ios03\" style=\"display: inline; background-image: none;\" alt=\"flutter_image_crop_ios03\" src=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/Flutter--_12DBA\/flutter_image_crop_ios03_thumb.png\" border=\"0\"><\/a><\/p>\n<p>Flutter\u3082\u30a8\u30e9\u30fc\u306e\u5d50\u3067\u3046\u3093\u3056\u308a\u3057\u304b\u3051\u305f\u304c\u3001Andro<a href=\"https:\/\/www.typea.info\/blog\/index.php\/2019\/10\/21\/flutter_androidx\">AndroidX\u306e\u4e92\u63db\u6027\u5bfe\u5fdc\u3067\u3001<\/a>\u4f55\u3068\u304b\u4e57\u308a\u5207\u308c\u305d\u3046\u304b!?<\/p>\n<p>mac\u306e\u64cd\u4f5c\u304c\u304e\u3053\u3061\u306a\u3044\u306e\u3067\u3001\u672c\u3067\u3082\u8cb7\u304a\u3046\u304b\u3057\u3089\u3002<\/p>\n<p><a href=\"https:\/\/developer.android.com\/kotlin\/ktx?hl=ja\"><br \/>\n<\/a><\/p>\n<p><a href=\"https:\/\/www.amazon.co.jp\/macOS-Catalina-%E3%83%91%E3%83%BC%E3%83%95%E3%82%A7%E3%82%AF%E3%83%88%E3%83%9E%E3%83%8B%E3%83%A5%E3%82%A2%E3%83%AB-%E4%BA%95%E6%9D%91-%E5%85%8B%E4%B9%9F\/dp\/4800712505\/ref=as_li_ss_il?__mk_ja_JP=%E3%82%AB%E3%82%BF%E3%82%AB%E3%83%8A&amp;keywords=Catalina&amp;qid=1571746220&amp;sr=8-1&amp;linkCode=li2&amp;tag=typea09-22&amp;linkId=75922b9d11670475f52fee501050ac56&amp;language=ja_JP\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" src=\"\/\/ws-fe.amazon-adsystem.com\/widgets\/q?_encoding=UTF8&amp;ASIN=4800712505&amp;Format=_SL160_&amp;ID=AsinImage&amp;MarketPlace=JP&amp;ServiceVersion=20070822&amp;WS=1&amp;tag=typea09-22&amp;language=ja_JP\" border=\"0\"><\/a><img loading=\"lazy\" decoding=\"async\" width=\"1\" height=\"1\" style=\"margin: 0px !important; border: currentcolor !important; border-image: none !important;\" alt=\"\" src=\"https:\/\/ir-jp.amazon-adsystem.com\/e\/ir?t=typea09-22&amp;language=ja_JP&amp;l=li2&amp;o=9&amp;a=4800712505\" border=\"0\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Flutter + Firebase \u3067\u30a2\u30d7\u30ea\u4f5c\u6210\u306e\u305f\u3081\u306e\u30d1\u30fc\u30c4\u3042\u3064\u3081\u3002 Flutter+Firebase\u74b0\u5883\u8a2d\u5b9a \u753b\u9762\u9077\u79fb Dialog Http\u30af\u30e9\u30a4\u30a2\u30f3\u30c8 AndroidX\u5bfe\u5fdc \u753b\u50cf\u306e\u9078\u629e \u307e\u3067\u3001Android\u3001i [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"sns_share_botton_hide":"","vkExUnit_sns_title":"","_vk_print_noindex":"","sitemap_hide":"","_veu_custom_css":"","veu_display_promotion_alert":"","vkexunit_cta_each_option":"","footnotes":""},"categories":[111],"tags":[],"class_list":["post-567","post","type-post","status-publish","format-standard","hentry","category-flutter"],"veu_head_title_object":{"title":"","add_site_title":""},"_links":{"self":[{"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/posts\/567","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/comments?post=567"}],"version-history":[{"count":1,"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/posts\/567\/revisions"}],"predecessor-version":[{"id":740,"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/posts\/567\/revisions\/740"}],"wp:attachment":[{"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=567"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/categories?post=567"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/tags?post=567"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}