Skip to content

Commit

Permalink
Fix export App Data in iOS.
Browse files Browse the repository at this point in the history
  • Loading branch information
3003h committed Nov 15, 2023
1 parent a89e307 commit ede5bc9
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 2 deletions.
3 changes: 3 additions & 0 deletions ios/Podfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@

# source 'https://github.com/CocoaPods/Specs.git'
$iOSVersion = '12.0'
platform :ios, $iOSVersion
# Pod::PICKER_MEDIA = false, Pod::PICKER_AUDIO = false

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'


project 'Runner', {
'Debug' => :debug,
'Profile' => :release,
Expand Down
2 changes: 1 addition & 1 deletion ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,6 @@ SPEC CHECKSUMS:
wakelock_plus: 8b09852c8876491e4b6d179e17dfe2a0b5f60d47
webview_cookie_manager: eaf920722b493bd0f7611b5484771ca53fed03f7

PODFILE CHECKSUM: 6f004977b01cf0ad335394c4de0550566a9e78e1
PODFILE CHECKSUM: 37eb07bc9c409a3149027062a82662a07901fb21

COCOAPODS: 1.12.1
2 changes: 2 additions & 0 deletions ios/Runner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -93,5 +93,7 @@
<false/>
<key>io.flutter.embedded_views_preview</key>
<string>YES</string>
<key>UISupportsDocumentBrowser</key>
<true/>
</dict>
</plist>
28 changes: 27 additions & 1 deletion lib/utils/import_export.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import 'package:file_picker/file_picker.dart';
import 'package:get/get.dart';
import 'package:intl/intl.dart';
import 'package:path/path.dart' as path;
import 'package:share_plus/share_plus.dart';
import 'package:shared_storage/shared_storage.dart' as ss;

Future<void> importQuickSearchFromFile() async {
Expand Down Expand Up @@ -71,7 +72,21 @@ Future<void> exportQuickSearchToFile() async {
logger.d('file: ${file?.uri}');
}
} else {
final saveToDirPath = await FilePicker.platform.getDirectoryPath();
if (Platform.isIOS) {
Share.shareXFiles([
XFile(
_tempFilePath,
mimeType: '*/*',
name: path.basename(_tempFilePath),
)
]);
return;
}

logger.d('saveToDirPath');
final saveToDirPath = await FilePicker.platform.getDirectoryPath(
dialogTitle: 'Save to',
);
logger.d('$saveToDirPath');
if (saveToDirPath != null) {
final _dstPath =
Expand Down Expand Up @@ -171,6 +186,17 @@ Future<void> exportAppDataToFile({bool base64 = true}) async {
logger.d('file: ${file?.uri}');
}
} else {
if (Platform.isIOS) {
Share.shareXFiles([
XFile(
tempFilePath,
mimeType: '*/*',
name: path.basename(tempFilePath),
)
]);
return;
}
logger.d('saveToDirPath');
final saveToDirPath = await FilePicker.platform.getDirectoryPath();
logger.d('saveToDirPath $saveToDirPath');
if (saveToDirPath != null) {
Expand Down

0 comments on commit ede5bc9

Please sign in to comment.