|
@@ -30,63 +30,6 @@ class MyHomePage extends StatefulWidget {
|
30
|
30
|
class _MyHomePageState extends State<MyHomePage> with LoadingDelegate {
|
31
|
31
|
String currentSelected = "";
|
32
|
32
|
|
33
|
|
- void _pickAsset(PickType type) async {
|
34
|
|
- List<AssetEntity> imgList = await PhotoPicker.pickAsset(
|
35
|
|
- // BuildContext required
|
36
|
|
- context: context,
|
37
|
|
-
|
38
|
|
- /// The following are optional parameters.
|
39
|
|
- themeColor: Colors.green,
|
40
|
|
- // the title color and bottom color
|
41
|
|
- padding: 1.0,
|
42
|
|
- // item padding
|
43
|
|
- dividerColor: Colors.grey,
|
44
|
|
- // divider color
|
45
|
|
- disableColor: Colors.grey.shade300,
|
46
|
|
- // the check box disable color
|
47
|
|
- itemRadio: 0.88,
|
48
|
|
- // the content item radio
|
49
|
|
- maxSelected: 8,
|
50
|
|
- // max picker image count
|
51
|
|
- // provider: I18nProvider.english,
|
52
|
|
- provider: I18nProvider.chinese,
|
53
|
|
- // i18n provider ,default is chinese. , you can custom I18nProvider or use ENProvider()
|
54
|
|
- rowCount: 3,
|
55
|
|
- // item row count
|
56
|
|
- textColor: Colors.white,
|
57
|
|
- // text color
|
58
|
|
- thumbSize: 150,
|
59
|
|
- // preview thumb size , default is 64
|
60
|
|
- sortDelegate: SortDelegate.common,
|
61
|
|
- // default is common ,or you make custom delegate to sort your gallery
|
62
|
|
- checkBoxBuilderDelegate: DefaultCheckBoxBuilderDelegate(
|
63
|
|
- activeColor: Colors.white,
|
64
|
|
- unselectedColor: Colors.white,
|
65
|
|
- ),
|
66
|
|
- // default is DefaultCheckBoxBuilderDelegate ,or you make custom delegate to create checkbox
|
67
|
|
-
|
68
|
|
- loadingDelegate: this,
|
69
|
|
- // if you want to build custom loading widget,extends LoadingDelegate, [see example/lib/main.dart]
|
70
|
|
-
|
71
|
|
- badgeDelegate: const DurationBadgeDelegate(),
|
72
|
|
- // badgeDelegate to show badge widget
|
73
|
|
-
|
74
|
|
- pickType: type,
|
75
|
|
- );
|
76
|
|
-
|
77
|
|
- if (imgList == null) {
|
78
|
|
- currentSelected = "not select item";
|
79
|
|
- } else {
|
80
|
|
- List<String> r = [];
|
81
|
|
- for (var e in imgList) {
|
82
|
|
- var file = await e.file;
|
83
|
|
- r.add(file.absolute.path);
|
84
|
|
- }
|
85
|
|
- currentSelected = r.join("\n\n");
|
86
|
|
- }
|
87
|
|
- setState(() {});
|
88
|
|
- }
|
89
|
|
-
|
90
|
33
|
@override
|
91
|
34
|
Widget buildBigImageLoading(
|
92
|
35
|
BuildContext context, AssetEntity entity, Color themeColor) {
|
|
@@ -120,6 +63,12 @@ class _MyHomePageState extends State<MyHomePage> with LoadingDelegate {
|
120
|
63
|
return new Scaffold(
|
121
|
64
|
appBar: new AppBar(
|
122
|
65
|
title: new Text(widget.title),
|
|
66
|
+ actions: <Widget>[
|
|
67
|
+ FlatButton(
|
|
68
|
+ child: Icon(Icons.image),
|
|
69
|
+ onPressed: _testPhotoListParams,
|
|
70
|
+ ),
|
|
71
|
+ ],
|
123
|
72
|
),
|
124
|
73
|
body: Container(
|
125
|
74
|
child: SingleChildScrollView(
|
|
@@ -152,6 +101,70 @@ class _MyHomePageState extends State<MyHomePage> with LoadingDelegate {
|
152
|
101
|
),
|
153
|
102
|
);
|
154
|
103
|
}
|
|
104
|
+
|
|
105
|
+ void _testPhotoListParams() async {
|
|
106
|
+ var assetPathList = await PhotoManager.getImageAsset();
|
|
107
|
+ _pickAsset(PickType.all, pathList: assetPathList);
|
|
108
|
+ }
|
|
109
|
+
|
|
110
|
+ void _pickAsset(PickType type, {List<AssetPathEntity> pathList}) async {
|
|
111
|
+ List<AssetEntity> imgList = await PhotoPicker.pickAsset(
|
|
112
|
+ // BuildContext required
|
|
113
|
+ context: context,
|
|
114
|
+
|
|
115
|
+ /// The following are optional parameters.
|
|
116
|
+ themeColor: Colors.green,
|
|
117
|
+ // the title color and bottom color
|
|
118
|
+ padding: 1.0,
|
|
119
|
+ // item padding
|
|
120
|
+ dividerColor: Colors.grey,
|
|
121
|
+ // divider color
|
|
122
|
+ disableColor: Colors.grey.shade300,
|
|
123
|
+ // the check box disable color
|
|
124
|
+ itemRadio: 0.88,
|
|
125
|
+ // the content item radio
|
|
126
|
+ maxSelected: 8,
|
|
127
|
+ // max picker image count
|
|
128
|
+ // provider: I18nProvider.english,
|
|
129
|
+ provider: I18nProvider.chinese,
|
|
130
|
+ // i18n provider ,default is chinese. , you can custom I18nProvider or use ENProvider()
|
|
131
|
+ rowCount: 3,
|
|
132
|
+ // item row count
|
|
133
|
+ textColor: Colors.white,
|
|
134
|
+ // text color
|
|
135
|
+ thumbSize: 150,
|
|
136
|
+ // preview thumb size , default is 64
|
|
137
|
+ sortDelegate: SortDelegate.common,
|
|
138
|
+ // default is common ,or you make custom delegate to sort your gallery
|
|
139
|
+ checkBoxBuilderDelegate: DefaultCheckBoxBuilderDelegate(
|
|
140
|
+ activeColor: Colors.white,
|
|
141
|
+ unselectedColor: Colors.white,
|
|
142
|
+ ),
|
|
143
|
+ // default is DefaultCheckBoxBuilderDelegate ,or you make custom delegate to create checkbox
|
|
144
|
+
|
|
145
|
+ loadingDelegate: this,
|
|
146
|
+ // if you want to build custom loading widget,extends LoadingDelegate, [see example/lib/main.dart]
|
|
147
|
+
|
|
148
|
+ badgeDelegate: const DurationBadgeDelegate(),
|
|
149
|
+ // badgeDelegate to show badge widget
|
|
150
|
+
|
|
151
|
+ pickType: type,
|
|
152
|
+
|
|
153
|
+ photoPathList: pathList,
|
|
154
|
+ );
|
|
155
|
+
|
|
156
|
+ if (imgList == null) {
|
|
157
|
+ currentSelected = "not select item";
|
|
158
|
+ } else {
|
|
159
|
+ List<String> r = [];
|
|
160
|
+ for (var e in imgList) {
|
|
161
|
+ var file = await e.file;
|
|
162
|
+ r.add(file.absolute.path);
|
|
163
|
+ }
|
|
164
|
+ currentSelected = r.join("\n\n");
|
|
165
|
+ }
|
|
166
|
+ setState(() {});
|
|
167
|
+ }
|
155
|
168
|
}
|
156
|
169
|
|
157
|
170
|
class IconTextButton extends StatelessWidget {
|