|
@@ -81,7 +81,6 @@ class _PhotoMainPageState extends State<PhotoMainPage>
|
81
|
81
|
@override
|
82
|
82
|
void initState() {
|
83
|
83
|
super.initState();
|
84
|
|
- _refreshList();
|
85
|
84
|
scaffoldKey = GlobalKey();
|
86
|
85
|
scrollController = ScrollController();
|
87
|
86
|
_changeThrottle = Throttle(onCall: _onAssetChange);
|
|
@@ -89,6 +88,14 @@ class _PhotoMainPageState extends State<PhotoMainPage>
|
89
|
88
|
PhotoManager.startChangeNotify();
|
90
|
89
|
}
|
91
|
90
|
|
|
91
|
+ @override
|
|
92
|
+ void didChangeDependencies() {
|
|
93
|
+ super.didChangeDependencies();
|
|
94
|
+ if (!_isInit) {
|
|
95
|
+ _refreshList();
|
|
96
|
+ }
|
|
97
|
+ }
|
|
98
|
+
|
92
|
99
|
@override
|
93
|
100
|
void dispose() {
|
94
|
101
|
PhotoManager.removeChangeCallback(_changeThrottle.call);
|
|
@@ -187,7 +194,8 @@ class _PhotoMainPageState extends State<PhotoMainPage>
|
187
|
194
|
);
|
188
|
195
|
}
|
189
|
196
|
|
190
|
|
- void _refreshList() {
|
|
197
|
+ void _refreshList() async {
|
|
198
|
+ await Future.delayed(Duration.zero);
|
191
|
199
|
if (!useAlbum) {
|
192
|
200
|
_refreshListFromWidget();
|
193
|
201
|
return;
|
|
@@ -197,15 +205,7 @@ class _PhotoMainPageState extends State<PhotoMainPage>
|
197
|
205
|
}
|
198
|
206
|
|
199
|
207
|
Future<void> _refreshListFromWidget() async {
|
200
|
|
- galleryPathList.clear();
|
201
|
|
- galleryPathList.addAll(widget.photoList);
|
202
|
|
- this.list.clear();
|
203
|
|
- var assetList = await galleryPathList[0].assetList;
|
204
|
|
- _sortAssetList(assetList);
|
205
|
|
- this.list.addAll(assetList);
|
206
|
|
- setState(() {
|
207
|
|
- _isInit = true;
|
208
|
|
- });
|
|
208
|
+ _onRefreshAssetPathList(widget.photoList);
|
209
|
209
|
}
|
210
|
210
|
|
211
|
211
|
Future<void> _refreshListFromGallery() async {
|
|
@@ -221,6 +221,10 @@ class _PhotoMainPageState extends State<PhotoMainPage>
|
221
|
221
|
pathList = await PhotoManager.getAssetPathList();
|
222
|
222
|
}
|
223
|
223
|
|
|
224
|
+ _onRefreshAssetPathList(pathList);
|
|
225
|
+ }
|
|
226
|
+
|
|
227
|
+ Future<void> _onRefreshAssetPathList(List<AssetPathEntity> pathList) async {
|
224
|
228
|
if (pathList == null) {
|
225
|
229
|
return;
|
226
|
230
|
}
|
|
@@ -246,10 +250,6 @@ class _PhotoMainPageState extends State<PhotoMainPage>
|
246
|
250
|
});
|
247
|
251
|
}
|
248
|
252
|
|
249
|
|
- void _sortAssetList(List<AssetEntity> assetList) {
|
250
|
|
- options?.sortDelegate?.assetDelegate?.sort(assetList);
|
251
|
|
- }
|
252
|
|
-
|
253
|
253
|
Widget _buildBody() {
|
254
|
254
|
if (!_isInit) {
|
255
|
255
|
return _buildLoading();
|
|
@@ -394,7 +394,7 @@ class _PhotoMainPageState extends State<PhotoMainPage>
|
394
|
394
|
}
|
395
|
395
|
|
396
|
396
|
void _onItemClick(AssetEntity data, int index) {
|
397
|
|
- var result = new PhotoPreviewResult();
|
|
397
|
+ var result = PhotoPreviewResult();
|
398
|
398
|
isPushed = true;
|
399
|
399
|
Navigator.of(context).push(
|
400
|
400
|
MaterialPageRoute(
|
|
@@ -425,7 +425,7 @@ class _PhotoMainPageState extends State<PhotoMainPage>
|
425
|
425
|
}
|
426
|
426
|
|
427
|
427
|
void _onTapPreview() async {
|
428
|
|
- var result = new PhotoPreviewResult();
|
|
428
|
+ var result = PhotoPreviewResult();
|
429
|
429
|
isPushed = true;
|
430
|
430
|
var v = await Navigator.of(context).push(
|
431
|
431
|
MaterialPageRoute(
|