|
@@ -1,3 +1,4 @@
|
|
1
|
+import 'package:flutter/cupertino.dart';
|
1
|
2
|
import 'package:flutter/material.dart';
|
2
|
3
|
import 'package:photo/photo.dart';
|
3
|
4
|
import 'package:photo_manager/photo_manager.dart';
|
|
@@ -26,32 +27,44 @@ class MyHomePage extends StatefulWidget {
|
26
|
27
|
_MyHomePageState createState() => new _MyHomePageState();
|
27
|
28
|
}
|
28
|
29
|
|
29
|
|
-class _MyHomePageState extends State<MyHomePage> {
|
|
30
|
+class _MyHomePageState extends State<MyHomePage> with LoadingDelegate {
|
30
|
31
|
String currentSelected = "";
|
31
|
32
|
|
32
|
33
|
void _pickImage() async {
|
33
|
34
|
List<AssetEntity> imgList = await PhotoPicker.pickImage(
|
34
|
|
- context: context, // BuildContext requied
|
|
35
|
+ context: context,
|
|
36
|
+ // BuildContext requied
|
35
|
37
|
|
36
|
38
|
/// The following are optional parameters.
|
37
|
|
- themeColor: Colors.green, // the title color and bottom color
|
38
|
|
- padding: 1.0, // item padding
|
39
|
|
- dividerColor: Colors.grey, // divider color
|
40
|
|
- disableColor: Colors.grey.shade300, // the check box disable color
|
41
|
|
- itemRadio: 0.88, // the content item radio
|
42
|
|
- maxSelected: 8, // max picker image count
|
43
|
|
- provider: I18nProvider
|
44
|
|
- .chinese, // i18n provider ,default is chinese. , you can custom I18nProvider or use ENProvider()
|
45
|
|
- rowCount: 5, // item row count
|
46
|
|
- textColor: Colors.white, // text color
|
47
|
|
- thumbSize: 150, // preview thumb size , default is 64
|
48
|
|
- sortDelegate: SortDelegate
|
49
|
|
- .common, // default is common ,or you make custom delegate to sort your gallery
|
50
|
|
- checkBoxBuilderDelegate:
|
51
|
|
- DefaultCheckBoxBuilderDelegate(
|
52
|
|
- activeColor: Colors.white,
|
53
|
|
- unselectedColor: Colors.white,
|
54
|
|
- ), // default is DefaultCheckBoxBuilderDelegate ,or you make custom delegate to create checkbox
|
|
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.chinese,
|
|
52
|
+ // i18n provider ,default is chinese. , you can custom I18nProvider or use ENProvider()
|
|
53
|
+ rowCount: 5,
|
|
54
|
+ // item row count
|
|
55
|
+ textColor: Colors.white,
|
|
56
|
+ // text color
|
|
57
|
+ thumbSize: 150,
|
|
58
|
+ // preview thumb size , default is 64
|
|
59
|
+ sortDelegate: SortDelegate.common,
|
|
60
|
+ // default is common ,or you make custom delegate to sort your gallery
|
|
61
|
+ checkBoxBuilderDelegate: DefaultCheckBoxBuilderDelegate(
|
|
62
|
+ activeColor: Colors.white,
|
|
63
|
+ unselectedColor: Colors.white,
|
|
64
|
+ ),
|
|
65
|
+ // default is D
|
|
66
|
+ loadingDelegate:
|
|
67
|
+ this, // efaultCheckBoxBuilderDelegate ,or you make custom delegate to create checkbox
|
55
|
68
|
);
|
56
|
69
|
|
57
|
70
|
if (imgList == null) {
|
|
@@ -67,6 +80,34 @@ class _MyHomePageState extends State<MyHomePage> {
|
67
|
80
|
setState(() {});
|
68
|
81
|
}
|
69
|
82
|
|
|
83
|
+ @override
|
|
84
|
+ Widget buildBigImageLoading(
|
|
85
|
+ BuildContext context, AssetEntity entity, Color themeColor) {
|
|
86
|
+ return Center(
|
|
87
|
+ child: Container(
|
|
88
|
+ width: 50.0,
|
|
89
|
+ height: 50.0,
|
|
90
|
+ child: CupertinoActivityIndicator(
|
|
91
|
+ radius: 25.0,
|
|
92
|
+ ),
|
|
93
|
+ ),
|
|
94
|
+ );
|
|
95
|
+ }
|
|
96
|
+
|
|
97
|
+ @override
|
|
98
|
+ Widget buildPreviewLoading(
|
|
99
|
+ BuildContext context, AssetEntity entity, Color themeColor) {
|
|
100
|
+ return Center(
|
|
101
|
+ child: Container(
|
|
102
|
+ width: 50.0,
|
|
103
|
+ height: 50.0,
|
|
104
|
+ child: CupertinoActivityIndicator(
|
|
105
|
+ radius: 25.0,
|
|
106
|
+ ),
|
|
107
|
+ ),
|
|
108
|
+ );
|
|
109
|
+ }
|
|
110
|
+
|
70
|
111
|
@override
|
71
|
112
|
Widget build(BuildContext context) {
|
72
|
113
|
return new Scaffold(
|