Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
ShareExtend
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
李增强
ShareExtend
Commits
2fff2f5d
Commit
2fff2f5d
authored
6 years ago
by
zhouteng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
更新readme和插件库版本
parent
a6165e59
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
52 deletions
+18
-52
README.md
README.md
+17
-51
pubspec.yaml
pubspec.yaml
+1
-1
No files found.
README.md
View file @
2fff2f5d
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
```
```
dependencies:
dependencies:
share_extend: "^1.0.
2
"
share_extend: "^1.0.
3
"
```
```
## 导入
## 导入
```
```
...
@@ -14,58 +14,24 @@ import 'package:share_extend/share_extend.dart';
...
@@ -14,58 +14,24 @@ import 'package:share_extend/share_extend.dart';
## 使用
## 使用
*
如果要分享手机外部存储(external storage)中的图片和文件,对于Android工程来说,
```
1) 需要配置WRITE_EXTERNAL_STORAGE权限,在android工程AndroidManifest.xml中配置
```
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
```
对于targetSdkVersion>=23的版本,需要动态获取权限
动态权限获取,可以借助其他第三方flutter插件来实现
2) 需要配置FileProvider来实现文件的分享,在android工程AndroidManifest.xml中配置
```
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="{your_authorities}"
android:grantUriPermissions="true"
android:exported="false">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/{your_provider_file}" />
</provider>
```
```
{your_authorities}``` 你定义的authorities
```
{your_provider_file}
``` 你的provider配置文件名
工程的res文件夹下,新建一个xml文件夹,添加一个{your_provider_file}的xml文件,配置类似如下:
```
//分享文本
<?xml version="1.0" encoding="utf-8"?>
ShareExtend.share("share text", "text");
<resources>
<paths>
<external-path
name="external_cache"
path="" />
</paths>
</resources>
```
### Dart中调用
```
//分享图片 (例子中使用了一个image_picker的插件来实现图片的选择)
// authorities 上面定义authorities
File f =
await ImagePicker.pickImage(source: ImageSource.gallery);
ShareExtend.share(f.path, "image");
//分享文本(只分享文本时,authorities参数是不必需的)
//分享文件
ShareExtend.share("share text", "text", authorities);
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");
//分享图片 (例子中使用了一个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);
```
This diff is collapsed.
Click to expand it.
pubspec.yaml
View file @
2fff2f5d
name
:
share_extend
name
:
share_extend
description
:
A flutter plugin to share text, image, file with system ui. It is compatible with both andorid and ios.
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 <qfszyq@gmail.com>
author
:
zhouteng <qfszyq@gmail.com>
homepage
:
https://github.com/zhouteng0217/ShareExtend
homepage
:
https://github.com/zhouteng0217/ShareExtend
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment