Browse Source

update pick state when gallery refresh

Caijinglong 5 years ago
parent
commit
8dd794045b
4 changed files with 22 additions and 4 deletions
  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 View File

1
+import 'dart:async';
2
+
1
 import 'package:photo_manager/photo_manager.dart';
3
 import 'package:photo_manager/photo_manager.dart';
2
 
4
 
3
 abstract class SelectedProvider {
5
 abstract class SelectedProvider {
41
   }
43
   }
42
 
44
 
43
   void sure();
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 View File

361
   void _onGalleryChange(AssetPathEntity assetPathEntity) {
361
   void _onGalleryChange(AssetPathEntity assetPathEntity) {
362
     _currentPath = assetPathEntity;
362
     _currentPath = assetPathEntity;
363
 
363
 
364
-    _currentPath.assetList.then((v) {
364
+    _currentPath.assetList.then((v)async {
365
       _sortAssetList(v);
365
       _sortAssetList(v);
366
       list.clear();
366
       list.clear();
367
       list.addAll(v);
367
       list.addAll(v);
368
       scrollController.jumpTo(0.0);
368
       scrollController.jumpTo(0.0);
369
+      await checkPickImageEntity();
369
       setState(() {});
370
       setState(() {});
370
     });
371
     });
371
   }
372
   }
499
     // Not deleted
500
     // Not deleted
500
     _onGalleryChange(this.currentPath);
501
     _onGalleryChange(this.currentPath);
501
   }
502
   }
503
+
502
 }
504
 }

+ 1
- 1
pubspec.lock View File

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

+ 2
- 2
pubspec.yaml View File

1
 name: photo
1
 name: photo
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.
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
 author: caijinglong<cjl_spy@163.com>
4
 author: caijinglong<cjl_spy@163.com>
5
 homepage: https://github.com/CaiJingLong/flutter_photo
5
 homepage: https://github.com/CaiJingLong/flutter_photo
6
 
6
 
11
   flutter:
11
   flutter:
12
     sdk: flutter
12
     sdk: flutter
13
 
13
 
14
-  photo_manager: ^0.3.0
14
+  photo_manager: ^0.3.1
15
   # photo_manager:
15
   # photo_manager:
16
   #   git:
16
   #   git:
17
   #     url: https://github.com/CaiJingLong/flutter_photo_manager.git
17
   #     url: https://github.com/CaiJingLong/flutter_photo_manager.git