|
@@ -1,30 +1,24 @@
|
1
|
1
|
# photo
|
2
|
2
|
|
3
|
|
-[![pub package](https://img.shields.io/pub/v/photo.svg)](https://pub.dartlang.org/packages/photo)
|
4
|
|
-[![GitHub](https://img.shields.io/github/license/CaiJingLong/flutter_photo.svg?style=flat-square)](https://github.com/CaiJingLong/flutter_photo)
|
5
|
|
-[![GitHub stars](https://img.shields.io/github/stars/CaiJingLong/flutter_photo.svg?style=social&label=Stars)](https://github.com/CaiJingLong/flutter_photo)
|
6
|
|
-
|
7
|
3
|
image picker, multi picker
|
8
|
4
|
|
9
|
5
|
support ios icloud
|
10
|
6
|
|
11
|
7
|
support video
|
12
|
8
|
|
|
9
|
+support camera
|
|
10
|
+
|
13
|
11
|
use flutter as ui
|
14
|
12
|
|
15
|
13
|
if you want to build custom ui, you just need api to make custom ui. to use [photo_manager](https://github.com/CaiJingLong/flutter_photo_manager) or fork the library to custom ui.
|
16
|
14
|
|
17
|
|
-## Screenshot
|
18
|
|
-
|
19
|
|
-![image](https://github.com/CaiJingLong/some_asset/blob/master/image_picker1.gif)
|
20
|
|
-
|
21
|
15
|
## install
|
22
|
16
|
|
23
|
|
-latest version : [![pub package](https://img.shields.io/pub/v/photo.svg)](https://pub.dartlang.org/packages/photo)
|
24
|
|
-
|
25
|
17
|
```yaml
|
26
|
18
|
dependencies:
|
27
|
|
- photo: $latest_version
|
|
19
|
+ photo:
|
|
20
|
+ git:
|
|
21
|
+ url: https://git.links123.net/lucky1213/mutli_image_picker.git
|
28
|
22
|
```
|
29
|
23
|
|
30
|
24
|
## Import
|
|
@@ -34,65 +28,80 @@ import 'package:photo/photo.dart';
|
34
|
28
|
import 'package:photo_manager/photo_manager.dart';
|
35
|
29
|
```
|
36
|
30
|
|
37
|
|
-## Usage
|
|
31
|
+## Usage 从相册选择
|
38
|
32
|
|
39
|
|
-### Simple use
|
|
33
|
+### 简单示例
|
40
|
34
|
|
41
|
35
|
```dart
|
42
|
36
|
void pickAssets() async {
|
43
|
|
- List<AssetEntity> assetList = await PhotoPicker.pickAsset(context: context);
|
44
|
|
- /// Use assetList to do something.
|
|
37
|
+ PickedEntity result = await PhotoPicker.pickAsset(
|
|
38
|
+ context: context,
|
|
39
|
+ provider: locale,
|
|
40
|
+ type: PickType.onlyImage,
|
|
41
|
+ );
|
|
42
|
+ /// Use assetList to do something.
|
45
|
43
|
}
|
46
|
44
|
```
|
47
|
45
|
|
48
|
|
-### More option
|
|
46
|
+### 更多的参数
|
49
|
47
|
|
50
|
48
|
The context is required, other params is optional.
|
51
|
49
|
|
52
|
50
|
```dart
|
53
|
51
|
void pickAsset() async {
|
54
|
|
- List<AssetEntity> imgList = await PhotoPicker.pickAsset(
|
55
|
|
- context: context,
|
56
|
|
- // BuildContext requied
|
57
|
|
-
|
58
|
|
- /// The following are optional parameters.
|
59
|
|
- themeColor: Colors.green,
|
60
|
|
- // the title color and bottom color
|
61
|
|
- padding: 1.0,
|
62
|
|
- // item padding
|
63
|
|
- dividerColor: Colors.grey,
|
64
|
|
- // divider color
|
65
|
|
- disableColor: Colors.grey.shade300,
|
66
|
|
- // the check box disable color
|
67
|
|
- itemRadio: 0.88,
|
68
|
|
- // the content item radio
|
69
|
|
- maxSelected: 8,
|
70
|
|
- // max picker image count
|
71
|
|
- provider: I18nProvider.chinese,
|
72
|
|
- // i18n provider ,default is chinese. , you can custom I18nProvider or use ENProvider()
|
73
|
|
- rowCount: 5,
|
74
|
|
- // item row count
|
75
|
|
- textColor: Colors.white,
|
76
|
|
- // text color
|
77
|
|
- thumbSize: 150,
|
78
|
|
- // preview thumb size , default is 64
|
79
|
|
- sortDelegate: SortDelegate.common,
|
80
|
|
- // default is common ,or you make custom delegate to sort your gallery
|
81
|
|
- checkBoxBuilderDelegate: DefaultCheckBoxBuilderDelegate(
|
82
|
|
- activeColor: Colors.white,
|
83
|
|
- unselectedColor: Colors.white,
|
84
|
|
- checkColor: Colors.blue,
|
85
|
|
- ), // default is DefaultCheckBoxBuilderDelegate ,or you make custom delegate to create checkbox
|
86
|
|
-
|
87
|
|
- loadingDelegate:
|
88
|
|
- this, // if you want to build custom loading widget,extends LoadingDelegate [see example/lib/main.dart]
|
89
|
|
-
|
90
|
|
- badgeDelegate: const DefaultBadgeDelegate(), /// or custom class extends [BadgeDelegate]
|
91
|
|
-
|
92
|
|
- pickType: type, // all/image/video
|
93
|
|
-
|
94
|
|
- List<AssetPathEntity> photoPathList, /// when [photoPathList] is not null , [pickType] invalid .
|
95
|
|
- );
|
|
52
|
+ PickedEntity result = await PhotoPicker.pickAsset(
|
|
53
|
+ // BuildContext requied
|
|
54
|
+ context: context,
|
|
55
|
+ // item row count
|
|
56
|
+ rowCount: 4,
|
|
57
|
+ // item radio
|
|
58
|
+ itemRadio: 1,
|
|
59
|
+ // max picker image count
|
|
60
|
+ maxSelected: 8,
|
|
61
|
+ // item padding
|
|
62
|
+ padding: 1,
|
|
63
|
+ // i18n provider ,default is chinese. , you can custom I18nProvider or use ENProvider()
|
|
64
|
+ provider: I18nProvider.chinese,
|
|
65
|
+ // preview thumb size , default is 128
|
|
66
|
+ thumbSize: 150,
|
|
67
|
+ // theme, 默认使用MaterialApp定义的theme
|
|
68
|
+ theme: PhotoTheme(),
|
|
69
|
+ // default is common ,or you make custom delegate to sort your gallery
|
|
70
|
+ sortDelegate: SortDelegate.common,
|
|
71
|
+ // if you want to build custom loading widget,extends LoadingDelegate [see example/lib/main.dart]
|
|
72
|
+ loadingDelegate: DefaultLoadingDelegate(),
|
|
73
|
+ // all/image/video
|
|
74
|
+ pickType: type,
|
|
75
|
+ // 可以理解为相册文件夹 when [photoPathList] is not null , [pickType] invalid .
|
|
76
|
+ List<AssetPathEntity> photoPathList,
|
|
77
|
+ // 已选择的asset
|
|
78
|
+ List<AssetEntity> pickedAssetList
|
|
79
|
+ );
|
|
80
|
+```
|
|
81
|
+
|
|
82
|
+## Usage 使用相机
|
|
83
|
+
|
|
84
|
+```dart
|
|
85
|
+void pickCamera() async {
|
|
86
|
+ // 参数来源自 ImagePicker.pickImage
|
|
87
|
+ File result = await PhotoPicker.pickCamera(
|
|
88
|
+ maxWidth: 100,
|
|
89
|
+ maxHeight: 100,
|
|
90
|
+ imageQuality: 100,
|
|
91
|
+ preferredCameraDevice: CameraDevice.rear,
|
|
92
|
+ );
|
|
93
|
+}
|
|
94
|
+```
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+### 关于`PickedEntity`
|
|
98
|
+
|
|
99
|
+```dart
|
|
100
|
+// 选中的assets 取消/默认 是空数组
|
|
101
|
+List<AssetEntity> asset
|
|
102
|
+
|
|
103
|
+// 是否是原图 默认 false
|
|
104
|
+bool isFullImage
|
96
|
105
|
```
|
97
|
106
|
|
98
|
107
|
### About photoPathList params
|
|
@@ -101,10 +110,6 @@ You can use [photo_manager] package to get `List<AssetPathEntity>` and handle or
|
101
|
110
|
|
102
|
111
|
This parameter is then passed into the `pickAsset` method, where the incoming photoList is rendered instead of the data in the album.
|
103
|
112
|
|
104
|
|
-## Whole example
|
105
|
|
-
|
106
|
|
-You can see [github](https://github.com/caijinglong/flutter_photo/blob/master/example/) [main.dart](https://github.com/caijinglong/flutter_photo/blob/master/example/lib/main.dart)
|
107
|
|
-
|
108
|
113
|
## About android
|
109
|
114
|
|
110
|
115
|
### Migrate to androidX
|
|
@@ -149,23 +154,6 @@ like next
|
149
|
154
|
<string>App need your agree, can visit your album</string>
|
150
|
155
|
```
|
151
|
156
|
|
152
|
|
-xcode like image
|
153
|
|
-![in xcode](https://github.com/CaiJingLong/some_asset/blob/master/flutter_photo2.png)
|
154
|
|
-
|
155
|
157
|
### Build error
|
156
|
158
|
|
157
|
159
|
if you build error like include of non-modular header inside framework module, see [#10](https://github.com/CaiJingLong/flutter_photo/issues/10) or [so](https://stackoverflow.com/questions/27776497/include-of-non-modular-header-inside-framework-module)
|
158
|
|
-
|
159
|
|
-## Thanks
|
160
|
|
-
|
161
|
|
-Part of the Android code comes from [debuggerx01](https://github.com/debuggerx01).
|
162
|
|
-
|
163
|
|
-## Donate
|
164
|
|
-
|
165
|
|
-If my code helps you, and you're willing to buy me a cup of coffee.
|
166
|
|
-
|
167
|
|
-you can use [paypal](https://paypal.me/caijinglong)
|
168
|
|
-
|
169
|
|
-or scan my alipay
|
170
|
|
-
|
171
|
|
-<img width="200px" src="https://raw.githubusercontent.com/CaiJingLong/asset_for_picgo/master/20181228213953.png"/>
|