From fea7343b60d692181bc8278a6e4af47ab74591c6 Mon Sep 17 00:00:00 2001 From: CodeDoctorDE Date: Wed, 7 Feb 2024 17:27:42 +0100 Subject: [PATCH] Fix file sharing on android, closes #585 --- app/lib/api/save_io.dart | 10 +++++++--- app/pubspec.lock | 20 +++++++++---------- .../metadata/android/en-US/changelogs/92.txt | 3 +++ 3 files changed, 20 insertions(+), 13 deletions(-) create mode 100644 fastlane/metadata/android/en-US/changelogs/92.txt diff --git a/app/lib/api/save_io.dart b/app/lib/api/save_io.dart index f4f47a3b0a45..da6366261212 100644 --- a/app/lib/api/save_io.dart +++ b/app/lib/api/save_io.dart @@ -4,6 +4,7 @@ import 'dart:typed_data'; import 'package:file_selector/file_selector.dart' as fs; import 'package:flutter/material.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart'; +import 'package:path_provider/path_provider.dart'; import 'package:share_plus/share_plus.dart'; Future exportFile( @@ -12,12 +13,15 @@ Future exportFile( String fileExtension, String mimeType, ) async { - final file = fs.XFile.fromData(Uint8List.fromList(bytes), - mimeType: mimeType, name: 'output.$fileExtension'); if (Platform.isAndroid || Platform.isIOS) { - Share.shareXFiles([file]); + final file = File( + '${(await getTemporaryDirectory()).path}/butterfly.$fileExtension'); + await file.writeAsBytes(bytes); + Share.shareXFiles([XFile(file.path)]); return; } + final file = fs.XFile.fromData(Uint8List.fromList(bytes), + mimeType: mimeType, name: 'output.$fileExtension'); final result = await fs.getSaveLocation( acceptedTypeGroups: [ fs.XTypeGroup( diff --git a/app/pubspec.lock b/app/pubspec.lock index f0523a93f535..bf8c0ce15672 100644 --- a/app/pubspec.lock +++ b/app/pubspec.lock @@ -188,10 +188,10 @@ packages: dependency: transitive description: name: camera_avfoundation - sha256: "7d0763dfcbf060f56aa254a68c103210280bee9e97bbe4fdef23e257a4f70ab9" + sha256: "608b56b0880722f703871329c4d7d4c2f379c8e2936940851df7fc041abc6f51" url: "https://pub.dev" source: hosted - version: "0.9.14" + version: "0.9.13+10" camera_platform_interface: dependency: transitive description: @@ -1382,26 +1382,26 @@ packages: dependency: transitive description: name: vector_graphics - sha256: "18f6690295af52d081f6808f2f7c69f0eed6d7e23a71539d75f4aeb8f0062172" + sha256: "4ac59808bbfca6da38c99f415ff2d3a5d7ca0a6b4809c71d9cf30fba5daf9752" url: "https://pub.dev" source: hosted - version: "1.1.9+2" + version: "1.1.10+1" vector_graphics_codec: dependency: transitive description: name: vector_graphics_codec - sha256: "531d20465c10dfac7f5cd90b60bbe4dd9921f1ec4ca54c83ebb176dbacb7bb2d" + sha256: f3247e7ab0ec77dc759263e68394990edc608fb2b480b80db8aa86ed09279e33 url: "https://pub.dev" source: hosted - version: "1.1.9+2" + version: "1.1.10+1" vector_graphics_compiler: dependency: transitive description: name: vector_graphics_compiler - sha256: "03012b0a33775c5530576b70240308080e1d5050f0faf000118c20e6463bc0ad" + sha256: "18489bdd8850de3dd7ca8a34e0c446f719ec63e2bab2e7a8cc66a9028dd76c5a" url: "https://pub.dev" source: hosted - version: "1.1.9+2" + version: "1.1.10+1" vector_math: dependency: transitive description: @@ -1499,5 +1499,5 @@ packages: source: hosted version: "3.1.2" sdks: - dart: ">=3.2.3 <4.0.0" - flutter: ">=3.16.6" + dart: ">=3.2.0 <4.0.0" + flutter: ">=3.16.0" diff --git a/fastlane/metadata/android/en-US/changelogs/92.txt b/fastlane/metadata/android/en-US/changelogs/92.txt new file mode 100644 index 000000000000..4b4c198811db --- /dev/null +++ b/fastlane/metadata/android/en-US/changelogs/92.txt @@ -0,0 +1,3 @@ +* Fix file sharing on android ([#585](https://github.com/LinwoodDev/Butterfly/issues/585)) + +Read more here: https://linwood.dev/butterfly/2.0.3-rc.1 \ No newline at end of file