getApplicationDocumentsDirectory static method

Future<String> getApplicationDocumentsDirectory()

获取应用文档目录

可能抛出 PlatformException 当原生平台调用失败时

Implementation

static Future<String> getApplicationDocumentsDirectory() async {
  try {
    final result = await _channel.invokeMethod<String>('getApplicationDocumentsDirectory');
    return result ?? "";
  } on PlatformException catch (e) {
    throw PlatformException(
      code: e.code,
      message: '获取应用文档目录失败: ${e.message}',
      details: e.details,
    );
  } catch (e) {
    throw Exception('获取应用文档目录时发生未知错误: $e');
  }
}