Skip to content

Commit

Permalink
Fix file sharing on android, closes #585
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeDoctorDE committed Feb 7, 2024
1 parent 0b59e3b commit fea7343
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 13 deletions.
10 changes: 7 additions & 3 deletions app/lib/api/save_io.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> exportFile(
Expand All @@ -12,12 +13,15 @@ Future<void> 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(
Expand Down
20 changes: 10 additions & 10 deletions app/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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"
3 changes: 3 additions & 0 deletions fastlane/metadata/android/en-US/changelogs/92.txt
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit fea7343

Please sign in to comment.