Bläddra i källkod

Use version 0.4.0 photo_manager .

Caijinglong 5 år sedan
förälder
incheckning
58e3e7f94e

+ 22
- 26
example/lib/asset_image.dart Visa fil

@@ -22,34 +22,30 @@ class AssetImageWidget extends StatelessWidget {
22 22
     if (assetEntity == null) {
23 23
       return _buildContainer();
24 24
     }
25
-    return FutureBuilder<Size>(
26
-      builder: (c, s) {
27
-        if (!s.hasData) {
28
-          return Container();
25
+    final size = assetEntity.size;
26
+
27
+    print(
28
+        "assetEntity.width = ${assetEntity.width} , assetEntity.height = ${assetEntity.height}");
29
+
30
+    return FutureBuilder<Uint8List>(
31
+      builder: (BuildContext context, snapshot) {
32
+        if (snapshot.hasData) {
33
+          return _buildContainer(
34
+            child: Image.memory(
35
+              snapshot.data,
36
+              width: width,
37
+              height: height,
38
+              fit: boxFit,
39
+            ),
40
+          );
41
+        } else {
42
+          return _buildContainer();
29 43
         }
30
-        var size = s.data;
31
-        return FutureBuilder<Uint8List>(
32
-          builder: (BuildContext context, snapshot) {
33
-            if (snapshot.hasData) {
34
-              return _buildContainer(
35
-                child: Image.memory(
36
-                  snapshot.data,
37
-                  width: width,
38
-                  height: height,
39
-                  fit: boxFit,
40
-                ),
41
-              );
42
-            } else {
43
-              return _buildContainer();
44
-            }
45
-          },
46
-          future: assetEntity.thumbDataWithSize(
47
-            size.width.toInt(),
48
-            size.height.toInt(),
49
-          ),
50
-        );
51 44
       },
52
-      future: assetEntity.size,
45
+      future: assetEntity.thumbDataWithSize(
46
+        width.toInt(),
47
+        height.toInt(),
48
+      ),
53 49
     );
54 50
   }
55 51
 

+ 1
- 1
lib/src/engine/throttle.dart Visa fil

@@ -21,7 +21,7 @@ class Throttle {
21 21
     this.duration = const Duration(seconds: 2),
22 22
   });
23 23
 
24
-  void call() {
24
+  void call(call) {
25 25
     if (!_isRunning) {
26 26
       _startTimer();
27 27
       onCall?.call();

+ 1
- 1
lib/src/ui/dialog/change_gallery_dialog.dart Visa fil

@@ -42,7 +42,7 @@ class _ChangeGalleryDialogState extends State<ChangeGalleryDialog> {
42 42
 
43 43
     return FlatButton(
44 44
       child: ListTile(
45
-        title: Text(text),
45
+        title: Text("$text (${entity.assetCount})"),
46 46
       ),
47 47
       onPressed: () {
48 48
         Navigator.pop(context, entity);

+ 8
- 17
lib/src/ui/page/main/image_item.dart Visa fil

@@ -54,23 +54,14 @@ class ImageItem extends StatelessWidget {
54 54
       height: double.infinity,
55 55
       fit: BoxFit.cover,
56 56
     );
57
-    // FutureBuilder()
58
-    var badge = FutureBuilder<Duration>(
59
-      future: entity.videoDuration,
60
-      builder: (ctx, snapshot) {
61
-        if (snapshot.hasData && snapshot != null) {
62
-          var buildBadge =
63
-              badgeDelegate?.buildBadge(context, entity.type, snapshot.data);
64
-          if (buildBadge == null) {
65
-            return Container();
66
-          } else {
67
-            return buildBadge;
68
-          }
69
-        } else {
70
-          return Container();
71
-        }
72
-      },
73
-    );
57
+    var badge;
58
+    final badgeBuilder =
59
+        badgeDelegate?.buildBadge(context, entity.type, entity.videoDuration);
60
+    if (badgeBuilder == null) {
61
+      badge = Container();
62
+    } else {
63
+      badge = badgeBuilder;
64
+    }
74 65
 
75 66
     return Stack(
76 67
       children: <Widget>[

+ 12
- 12
lib/src/ui/page/photo_main_page.dart Visa fil

@@ -44,7 +44,7 @@ class _PhotoMainPageState extends State<PhotoMainPage>
44 44
 
45 45
   Color get themeColor => options.themeColor;
46 46
 
47
-  AssetPathEntity _currentPath = AssetPathEntity.all;
47
+  AssetPathEntity _currentPath;
48 48
 
49 49
   bool _isInit = false;
50 50
 
@@ -60,10 +60,10 @@ class _PhotoMainPageState extends State<PhotoMainPage>
60 60
   }
61 61
 
62 62
   String get currentGalleryName {
63
-    if (currentPath.isAll) {
63
+    if (currentPath?.isAll == true) {
64 64
       return i18nProvider.getAllGalleryText(options);
65 65
     }
66
-    return currentPath.name;
66
+    return currentPath?.name ?? "";
67 67
   }
68 68
 
69 69
   GlobalKey scaffoldKey;
@@ -412,15 +412,15 @@ class _PhotoMainPageState extends State<PhotoMainPage>
412 412
     var v = await Navigator.of(context).push(
413 413
       MaterialPageRoute(
414 414
         builder: (ctx) => ConfigProvider(
415
-              provider: ConfigProvider.of(context).provider,
416
-              options: options,
417
-              child: PhotoPreviewPage(
418
-                selectedProvider: this,
419
-                list: List.of(selectedList),
420
-                changeProviderOnCheckChange: false,
421
-                result: result,
422
-              ),
423
-            ),
415
+          provider: ConfigProvider.of(context).provider,
416
+          options: options,
417
+          child: PhotoPreviewPage(
418
+            selectedProvider: this,
419
+            list: List.of(selectedList),
420
+            changeProviderOnCheckChange: false,
421
+            result: result,
422
+          ),
423
+        ),
424 424
       ),
425 425
     );
426 426
     if (handlePreviewResult(v)) {

+ 12
- 10
pubspec.lock Visa fil

@@ -1,5 +1,5 @@
1 1
 # Generated by pub
2
-# See https://www.dartlang.org/tools/pub/glossary#lockfile
2
+# See https://dart.dev/tools/pub/glossary#lockfile
3 3
 packages:
4 4
   async:
5 5
     dependency: transitive
@@ -7,7 +7,7 @@ packages:
7 7
       name: async
8 8
       url: "https://pub.flutter-io.cn"
9 9
     source: hosted
10
-    version: "2.1.0"
10
+    version: "2.2.0"
11 11
   boolean_selector:
12 12
     dependency: transitive
13 13
     description:
@@ -66,21 +66,23 @@ packages:
66 66
       name: pedantic
67 67
       url: "https://pub.flutter-io.cn"
68 68
     source: hosted
69
-    version: "1.5.0"
69
+    version: "1.7.0"
70 70
   photo_manager:
71 71
     dependency: "direct main"
72 72
     description:
73
-      name: photo_manager
74
-      url: "https://pub.flutter-io.cn"
75
-    source: hosted
76
-    version: "0.3.4"
73
+      path: "."
74
+      ref: ffaa6e8470708e63c3456837c8bd6eef7b0d42df
75
+      resolved-ref: ffaa6e8470708e63c3456837c8bd6eef7b0d42df
76
+      url: "https://github.com/CaiJingLong/flutter_photo_manager.git"
77
+    source: git
78
+    version: "0.4.0"
77 79
   quiver:
78 80
     dependency: transitive
79 81
     description:
80 82
       name: quiver
81 83
       url: "https://pub.flutter-io.cn"
82 84
     source: hosted
83
-    version: "2.0.2"
85
+    version: "2.0.3"
84 86
   sky_engine:
85 87
     dependency: transitive
86 88
     description: flutter
@@ -127,7 +129,7 @@ packages:
127 129
       name: test_api
128 130
       url: "https://pub.flutter-io.cn"
129 131
     source: hosted
130
-    version: "0.2.4"
132
+    version: "0.2.5"
131 133
   typed_data:
132 134
     dependency: transitive
133 135
     description:
@@ -143,4 +145,4 @@ packages:
143 145
     source: hosted
144 146
     version: "2.0.8"
145 147
 sdks:
146
-  dart: ">=2.2.0 <3.0.0"
148
+  dart: ">=2.2.2 <3.0.0"

+ 5
- 5
pubspec.yaml Visa fil

@@ -11,11 +11,11 @@ dependencies:
11 11
   flutter:
12 12
     sdk: flutter
13 13
 
14
-  photo_manager: ^0.3.4
15
-  # photo_manager:
16
-  #   git:
17
-  #     url: https://github.com/CaiJingLong/flutter_photo_manager.git
18
-  #     ref: 2e4821c1fa797272e4c454366b4fb264e8a054d6
14
+  # photo_manager: ^0.3.4
15
+  photo_manager:
16
+    git:
17
+      url: https://github.com/CaiJingLong/flutter_photo_manager.git
18
+      ref: ffaa6e8470708e63c3456837c8bd6eef7b0d42df
19 19
   # photo_manager:
20 20
   #   path: ../flutter_photo_manager
21 21