Преглед изворни кода

update pick state when gallery refresh

Caijinglong пре 5 година
родитељ
комит
8dd794045b
4 измењених фајлова са 22 додато и 4 уклоњено
  1. 16
    0
      lib/src/provider/selected_provider.dart
  2. 3
    1
      lib/src/ui/page/photo_main_page.dart
  3. 1
    1
      pubspec.lock
  4. 2
    2
      pubspec.yaml

+ 16
- 0
lib/src/provider/selected_provider.dart Прегледај датотеку

@@ -1,3 +1,5 @@
1
+import 'dart:async';
2
+
1 3
 import 'package:photo_manager/photo_manager.dart';
2 4
 
3 5
 abstract class SelectedProvider {
@@ -41,4 +43,18 @@ abstract class SelectedProvider {
41 43
   }
42 44
 
43 45
   void sure();
46
+
47
+  Future checkPickImageEntity() async {
48
+    List<AssetEntity> notExistsList = [];
49
+    for (var entity in selectedList) {
50
+      var exists = await entity.exists;
51
+      if (!exists) {
52
+        notExistsList.add(entity);
53
+      }
54
+    }
55
+
56
+    selectedList.removeWhere((e) {
57
+      return notExistsList.contains(e);
58
+    });
59
+  }
44 60
 }

+ 3
- 1
lib/src/ui/page/photo_main_page.dart Прегледај датотеку

@@ -361,11 +361,12 @@ class _PhotoMainPageState extends State<PhotoMainPage>
361 361
   void _onGalleryChange(AssetPathEntity assetPathEntity) {
362 362
     _currentPath = assetPathEntity;
363 363
 
364
-    _currentPath.assetList.then((v) {
364
+    _currentPath.assetList.then((v)async {
365 365
       _sortAssetList(v);
366 366
       list.clear();
367 367
       list.addAll(v);
368 368
       scrollController.jumpTo(0.0);
369
+      await checkPickImageEntity();
369 370
       setState(() {});
370 371
     });
371 372
   }
@@ -499,4 +500,5 @@ class _PhotoMainPageState extends State<PhotoMainPage>
499 500
     // Not deleted
500 501
     _onGalleryChange(this.currentPath);
501 502
   }
503
+
502 504
 }

+ 1
- 1
pubspec.lock Прегледај датотеку

@@ -73,7 +73,7 @@ packages:
73 73
       name: photo_manager
74 74
       url: "https://pub.flutter-io.cn"
75 75
     source: hosted
76
-    version: "0.3.0"
76
+    version: "0.3.1"
77 77
   quiver:
78 78
     dependency: transitive
79 79
     description:

+ 2
- 2
pubspec.yaml Прегледај датотеку

@@ -1,6 +1,6 @@
1 1
 name: photo
2 2
 description: image picker, multi picker support video / icloud asset ,use flutter as ui, if you want to build custom ui,you just use photo_manager.
3
-version: 0.3.0
3
+version: 0.3.1
4 4
 author: caijinglong<cjl_spy@163.com>
5 5
 homepage: https://github.com/CaiJingLong/flutter_photo
6 6
 
@@ -11,7 +11,7 @@ dependencies:
11 11
   flutter:
12 12
     sdk: flutter
13 13
 
14
-  photo_manager: ^0.3.0
14
+  photo_manager: ^0.3.1
15 15
   # photo_manager:
16 16
   #   git:
17 17
   #     url: https://github.com/CaiJingLong/flutter_photo_manager.git