|
|
@@ -107,13 +107,23 @@ deleteDirectory(String path) async {
|
|
|
|
|
|
|
|
|
|
|
|
-Future<String?> getSaveLocation({String? suggestedName}) async {
|
|
|
+Future<String?> getSaveLocation({required String suggestedName, String? iOSAppDirectory}) async {
|
|
|
if (Platform.isIOS) {
|
|
|
- final directory = await getApplicationDocumentsDirectory();
|
|
|
-
|
|
|
- Log.d('iOS get file path: ${directory.path}/$suggestedName');
|
|
|
-
|
|
|
- return '${directory.path}/$suggestedName';
|
|
|
+ final docDir = await getApplicationDocumentsDirectory();
|
|
|
+ String path = docDir.path;
|
|
|
+ if (iOSAppDirectory != null) {
|
|
|
+ path = '${docDir.path}/$iOSAppDirectory';
|
|
|
+ }
|
|
|
+ Directory dir = Directory(path);
|
|
|
+ // 检查文件夹是否已经存在
|
|
|
+ bool exists = await dir.exists();
|
|
|
+ if (!exists) {
|
|
|
+ // 如果文件夹不存在,则创建它
|
|
|
+ await dir.create(recursive: true); // 设置 recursive 为 true 可以创建多级目录
|
|
|
+ }
|
|
|
+ final finalPath = File('${dir.path}/$suggestedName').path;
|
|
|
+ // Log.d('iOS get file path: $finalPath');
|
|
|
+ return finalPath;
|
|
|
|
|
|
} else {
|
|
|
final file_selector.FileSaveLocation? selectedFile = await file_selector.getSaveLocation(
|