Quellcode durchsuchen

Use version 0.4.0 photo_manager .

Caijinglong vor 5 Jahren
Ursprung
Commit
58e3e7f94e

+ 22
- 26
example/lib/asset_image.dart Datei anzeigen

22
     if (assetEntity == null) {
22
     if (assetEntity == null) {
23
       return _buildContainer();
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 Datei anzeigen

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

+ 1
- 1
lib/src/ui/dialog/change_gallery_dialog.dart Datei anzeigen

42
 
42
 
43
     return FlatButton(
43
     return FlatButton(
44
       child: ListTile(
44
       child: ListTile(
45
-        title: Text(text),
45
+        title: Text("$text (${entity.assetCount})"),
46
       ),
46
       ),
47
       onPressed: () {
47
       onPressed: () {
48
         Navigator.pop(context, entity);
48
         Navigator.pop(context, entity);

+ 8
- 17
lib/src/ui/page/main/image_item.dart Datei anzeigen

54
       height: double.infinity,
54
       height: double.infinity,
55
       fit: BoxFit.cover,
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
     return Stack(
66
     return Stack(
76
       children: <Widget>[
67
       children: <Widget>[

+ 12
- 12
lib/src/ui/page/photo_main_page.dart Datei anzeigen

44
 
44
 
45
   Color get themeColor => options.themeColor;
45
   Color get themeColor => options.themeColor;
46
 
46
 
47
-  AssetPathEntity _currentPath = AssetPathEntity.all;
47
+  AssetPathEntity _currentPath;
48
 
48
 
49
   bool _isInit = false;
49
   bool _isInit = false;
50
 
50
 
60
   }
60
   }
61
 
61
 
62
   String get currentGalleryName {
62
   String get currentGalleryName {
63
-    if (currentPath.isAll) {
63
+    if (currentPath?.isAll == true) {
64
       return i18nProvider.getAllGalleryText(options);
64
       return i18nProvider.getAllGalleryText(options);
65
     }
65
     }
66
-    return currentPath.name;
66
+    return currentPath?.name ?? "";
67
   }
67
   }
68
 
68
 
69
   GlobalKey scaffoldKey;
69
   GlobalKey scaffoldKey;
412
     var v = await Navigator.of(context).push(
412
     var v = await Navigator.of(context).push(
413
       MaterialPageRoute(
413
       MaterialPageRoute(
414
         builder: (ctx) => ConfigProvider(
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
     if (handlePreviewResult(v)) {
426
     if (handlePreviewResult(v)) {

+ 12
- 10
pubspec.lock Datei anzeigen

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

+ 5
- 5
pubspec.yaml Datei anzeigen

11
   flutter:
11
   flutter:
12
     sdk: flutter
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
   # photo_manager:
19
   # photo_manager:
20
   #   path: ../flutter_photo_manager
20
   #   path: ../flutter_photo_manager
21
 
21