Browse Source

chore(mobile): Update share_file to latest version and migrate to using cross platform shareXFile (#1476)

* update share_plus and use sharexfile

* rename variable
martyfuhry 2 years ago
parent
commit
f23979024a
3 changed files with 13 additions and 41 deletions
  1. 5 5
      mobile/lib/shared/services/share.service.dart
  2. 7 35
      mobile/pubspec.lock
  3. 1 1
      mobile/pubspec.yaml

+ 5 - 5
mobile/lib/shared/services/share.service.dart

@@ -22,7 +22,7 @@ class ShareService {
   }
 
   Future<void> shareAssets(List<Asset> assets) async {
-    final downloadedFilePaths = assets.map((asset) async {
+    final downloadedXFiles = assets.map<Future<XFile>>((asset) async {
       if (asset.isRemote) {
         final tempDir = await getTemporaryDirectory();
         final fileName = basename(asset.remote!.originalPath);
@@ -33,16 +33,16 @@ class ShareService {
           isWeb: false,
         );
         tempFile.writeAsBytesSync(res.bodyBytes);
-        return tempFile.path;
+        return XFile(tempFile.path);
       } else {
         File? f = await asset.local!.file;
-        return f!.path;
+        return XFile(f!.path);
       }
     });
 
     // ignore: deprecated_member_use
-    Share.shareFiles(
-      await Future.wait(downloadedFilePaths),
+    Share.shareXFiles(
+      await Future.wait(downloadedXFiles),
       sharePositionOrigin: Rect.zero,
     );
   }

+ 7 - 35
mobile/pubspec.lock

@@ -210,7 +210,7 @@ packages:
       name: cross_file
       url: "https://pub.dartlang.org"
     source: hosted
-    version: "0.3.3+1"
+    version: "0.3.3+2"
   crypto:
     dependency: transitive
     description:
@@ -868,42 +868,14 @@ packages:
       name: share_plus
       url: "https://pub.dartlang.org"
     source: hosted
-    version: "4.0.10"
-  share_plus_linux:
-    dependency: transitive
-    description:
-      name: share_plus_linux
-      url: "https://pub.dartlang.org"
-    source: hosted
-    version: "3.0.0"
-  share_plus_macos:
-    dependency: transitive
-    description:
-      name: share_plus_macos
-      url: "https://pub.dartlang.org"
-    source: hosted
-    version: "3.0.1"
+    version: "6.3.0"
   share_plus_platform_interface:
     dependency: transitive
     description:
       name: share_plus_platform_interface
       url: "https://pub.dartlang.org"
     source: hosted
-    version: "3.0.3"
-  share_plus_web:
-    dependency: transitive
-    description:
-      name: share_plus_web
-      url: "https://pub.dartlang.org"
-    source: hosted
-    version: "3.0.1"
-  share_plus_windows:
-    dependency: transitive
-    description:
-      name: share_plus_windows
-      url: "https://pub.dartlang.org"
-    source: hosted
-    version: "3.0.1"
+    version: "3.2.0"
   shared_preferences:
     dependency: transitive
     description:
@@ -1174,14 +1146,14 @@ packages:
       name: url_launcher_platform_interface
       url: "https://pub.dartlang.org"
     source: hosted
-    version: "2.0.5"
+    version: "2.1.1"
   url_launcher_web:
     dependency: transitive
     description:
       name: url_launcher_web
       url: "https://pub.dartlang.org"
     source: hosted
-    version: "2.0.11"
+    version: "2.0.14"
   url_launcher_windows:
     dependency: transitive
     description:
@@ -1279,7 +1251,7 @@ packages:
       name: wakelock_windows
       url: "https://pub.dartlang.org"
     source: hosted
-    version: "0.2.0"
+    version: "0.2.1"
   watcher:
     dependency: transitive
     description:
@@ -1307,7 +1279,7 @@ packages:
       name: win32
       url: "https://pub.dartlang.org"
     source: hosted
-    version: "2.7.0"
+    version: "3.1.3"
   wkt_parser:
     dependency: transitive
     description:

+ 1 - 1
mobile/pubspec.yaml

@@ -32,7 +32,7 @@ dependencies:
   http: 0.13.4
   cancellation_token_http: ^1.1.0
   easy_localization: ^3.0.1
-  share_plus: ^4.0.10
+  share_plus: ^6.3.0
   flutter_displaymode: ^0.4.0
   scrollable_positioned_list: ^0.3.4
   path: ^1.8.1