From 2fff2f5d74a07dea2fbaf8c6f134d0b4b68c411c Mon Sep 17 00:00:00 2001 From: zhouteng Date: Tue, 18 Dec 2018 01:44:00 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0readme=E5=92=8C=E6=8F=92?= =?UTF-8?q?=E4=BB=B6=E5=BA=93=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 68 +++++++++++++--------------------------------------- pubspec.yaml | 2 +- 2 files changed, 18 insertions(+), 52 deletions(-) diff --git a/README.md b/README.md index 3367cdd..4700728 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ ``` dependencies: - share_extend: "^1.0.2" + share_extend: "^1.0.3" ``` ## 导入 ``` @@ -14,58 +14,24 @@ import 'package:share_extend/share_extend.dart'; ## 使用 -* 如果要分享手机外部存储(external storage)中的图片和文件,对于Android工程来说, - 1) 需要配置WRITE_EXTERNAL_STORAGE权限,在android工程AndroidManifest.xml中配置 - ``` - - ``` - 对于targetSdkVersion>=23的版本,需要动态获取权限 - 动态权限获取,可以借助其他第三方flutter插件来实现 - - 2) 需要配置FileProvider来实现文件的分享,在android工程AndroidManifest.xml中配置 - - ``` - - - - ``` - ```{your_authorities}``` 你定义的authorities +``` - ```{your_provider_file}``` 你的provider配置文件名 +//分享文本 +ShareExtend.share("share text", "text"); - 工程的res文件夹下,新建一个xml文件夹,添加一个{your_provider_file}的xml文件,配置类似如下: +//分享图片 (例子中使用了一个image_picker的插件来实现图片的选择) +File f = + await ImagePicker.pickImage(source: ImageSource.gallery); +ShareExtend.share(f.path, "image"); - ``` - - - - - - - ``` - ### Dart中调用 +//分享文件 +Directory dir = await getApplicationDocumentsDirectory(); +File testFile = new File("${dir.path}/flutter/test.txt"); +if (!await testFile.exists()) { + await testFile.create(recursive: true); + testFile.writeAsStringSync("test for share documents file"); +} +ShareExtend.share(testFile.path, "file"); - ``` - // authorities 上面定义authorities - - //分享文本(只分享文本时,authorities参数是不必需的) - ShareExtend.share("share text", "text", authorities); - - //分享图片 (例子中使用了一个image_picker的插件来实现图片的选择) - File f = - await ImagePicker.pickImage(source: ImageSource.gallery); - ShareExtend.share(f.path, "image", authorities); - //分享文件 - File f = - await ImagePicker.pickImage(source: ImageSource.gallery); - ShareExtend.share(f.path, "file", authorities); - ``` +``` diff --git a/pubspec.yaml b/pubspec.yaml index 9869fd9..8bd1b06 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: share_extend description: A flutter plugin to share text, image, file with system ui. It is compatible with both andorid and ios. -version: 1.0.2 +version: 1.0.3 author: zhouteng homepage: https://github.com/zhouteng0217/ShareExtend