ios get data dir

Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
fufesou
2022-12-01 21:48:19 +08:00
parent 60d0b9209b
commit 387a7f2df4
7 changed files with 34 additions and 40 deletions

View File

@@ -29,6 +29,7 @@ typedef HandleEvent = Future<void> Function(Map<String, dynamic> evt);
/// Hides the platform differences.
class PlatformFFI {
String _dir = '';
// _homeDir is only needed for Android and IOS.
String _homeDir = '';
F2? _translate;
final _eventHandlers = <String, Map<String, HandleEvent>>{};
@@ -119,8 +120,10 @@ class PlatformFFI {
if (isAndroid) {
// only support for android
_homeDir = (await ExternalPath.getExternalStorageDirectories())[0];
} else if (isIOS) {
_homeDir = _ffiBind.mainGetDataDirIos();
} else {
_homeDir = (await getDownloadsDirectory())?.path ?? '';
// no need to set home dir
}
} catch (e) {
debugPrint('initialize failed: $e');
@@ -159,8 +162,13 @@ class PlatformFFI {
name = macOsInfo.computerName;
id = macOsInfo.systemGUID ?? '';
}
debugPrint(
'_appType:$_appType,info1-id:$id,info2-name:$name,dir:$_dir,homeDir:$_homeDir');
if (isAndroid || isIOS) {
debugPrint(
'_appType:$_appType,info1-id:$id,info2-name:$name,dir:$_dir,homeDir:$_homeDir');
} else {
debugPrint(
'_appType:$_appType,info1-id:$id,info2-name:$name,dir:$_dir');
}
await _ffiBind.mainDeviceId(id: id);
await _ffiBind.mainDeviceName(name: name);
await _ffiBind.mainSetHomeDir(home: _homeDir);