diff --git a/.dart_tool/package_config.json b/.dart_tool/package_config.json index d01ffc7..691ec40 100644 --- a/.dart_tool/package_config.json +++ b/.dart_tool/package_config.json @@ -235,12 +235,6 @@ "packageUri": "lib/", "languageVersion": "1.20" }, - { - "name": "image_gallery_saver", - "rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/image_gallery_saver-1.5.0", - "packageUri": "lib/", - "languageVersion": "2.1" - }, { "name": "image_picker", "rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/image_picker-0.6.7+11", @@ -253,6 +247,12 @@ "packageUri": "lib/", "languageVersion": "2.5" }, + { + "name": "image_save", + "rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/image_save-3.1.1", + "packageUri": "lib/", + "languageVersion": "2.1" + }, { "name": "intl", "rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/intl-0.16.1", @@ -584,7 +584,7 @@ "languageVersion": "2.1" } ], - "generated": "2020-09-27T11:21:02.505016Z", + "generated": "2020-09-27T12:18:22.038779Z", "generator": "pub", "generatorVersion": "2.7.2" } diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index 8250e30..bc03d46 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -38,6 +38,8 @@ PODS: - TOCropViewController (~> 2.5.2) - image_picker (0.0.1): - Flutter + - image_save (0.0.1): + - Flutter - jdsdk (0.0.1): - Flutter - mtopSDK (3.0.0.3-BC) @@ -104,6 +106,7 @@ DEPENDENCIES: - fluttertoast (from `.symlinks/plugins/fluttertoast/ios`) - image_cropper (from `.symlinks/plugins/image_cropper/ios`) - image_picker (from `.symlinks/plugins/image_picker/ios`) + - image_save (from `.symlinks/plugins/image_save/ios`) - jdsdk (from `.symlinks/plugins/jdsdk/ios`) - package_info (from `.symlinks/plugins/package_info/ios`) - path_provider (from `.symlinks/plugins/path_provider/ios`) @@ -164,6 +167,8 @@ EXTERNAL SOURCES: :path: ".symlinks/plugins/image_cropper/ios" image_picker: :path: ".symlinks/plugins/image_picker/ios" + image_save: + :path: ".symlinks/plugins/image_save/ios" jdsdk: :path: ".symlinks/plugins/jdsdk/ios" package_info: @@ -222,6 +227,7 @@ SPEC CHECKSUMS: FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a image_cropper: 3c16d7651730ffe85897f5a1c4e2547e6b54989a image_picker: 9c3312491f862b28d21ecd8fdf0ee14e601b3f09 + image_save: 66ab41fa2c60bc9569e55563ea287cced7b79fd1 jdsdk: 2ca38c7e3a2dfb0f3641425f8fd1e8d20357693f mtopSDK: d6fdf81730342a69be920b576541c7bb81a683d5 package_info: 873975fc26034f0b863a300ad47e7f1ac6c7ec62 diff --git a/lib/pages/favorite_page.dart b/lib/pages/favorite_page.dart index c7bf497..25c67eb 100644 --- a/lib/pages/favorite_page.dart +++ b/lib/pages/favorite_page.dart @@ -1,10 +1,11 @@ import 'dart:typed_data'; +import 'dart:ui' as ui; import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; +import 'package:zhiying_comm/zhiying_comm.dart'; import 'package:zhiying_base_widget/template/goods_share_template/goods_share_template.dart'; - -import 'package:image_gallery_saver/image_gallery_saver.dart'; +import 'package:image_save/image_save.dart'; class FavoritePage extends StatefulWidget { @override @@ -31,24 +32,29 @@ class _FavoritePageState extends State { FlatButton( child: Icon(Icons.add), onPressed: () async { - BuildContext buildContext = globalKey.currentContext; + try { + BuildContext buildContext = globalKey.currentContext; + + if (null != buildContext) { + RenderRepaintBoundary boundary = + buildContext.findRenderObject(); + var image = await boundary.toImage(); + ByteData byteData = + await image.toByteData(format: ui.ImageByteFormat.png); - if (null != buildContext) { - RenderRepaintBoundary boundary = - buildContext.findRenderObject(); - var image = await boundary.toImage(); - ByteData byteData = - await image.toByteData(format: ui.ImageByteFormat.png); - // final result = await ImageGallerySaver.saveImage( - // byteData.buffer.asUint8List()); - // var response = await Dio().get( - // "https://ss0.baidu.com/94o3dSag_xI4khGko9WTAnF6hhy/image/h%3D300/sign=a62e824376d98d1069d40a31113eb807/838ba61ea8d3fd1fc9c7b6853a4e251f94ca5f46.jpg", - // options: Options(responseType: ResponseType.bytes)); - // final result = await ImageGallerySaver.saveImage( - // Uint8List.fromList(image), - // quality: 60, - // name: "hello"); - // print(result); + // final result = await ImageGallerySaver.saveImage( + // byteData.buffer.asUint8List()); + // var response = await Dio().get( + // "https://ss0.baidu.com/94o3dSag_xI4khGko9WTAnF6hhy/image/h%3D300/sign=a62e824376d98d1069d40a31113eb807/838ba61ea8d3fd1fc9c7b6853a4e251f94ca5f46.jpg", + // options: Options(responseType: ResponseType.bytes)); + bool success = await ImageSave.saveImageToSandbox( + byteData.buffer.asUint8List(), "demo.png"); + print('${success}'); + // print(result); + } + cache(err) { + Logger.error(err); + } } }, ) diff --git a/pubspec.yaml b/pubspec.yaml index 740f414..e4b4f86 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -19,7 +19,7 @@ dependencies: image_picker: ^0.6.7+3 tab_indicator_styler: 1.0.0 connectivity: ^0.4.9+3 - image_gallery_saver: ^1.5.0 + image_save: ^3.1.1 image_cropper: git: url: 'http://192.168.0.138:3000/FnuoOS_Flutter_Components/Image_Cropper.git'