createPath static method

Future<bool> createPath({
  1. required String path,
})

创建目录

path 要创建的目录路径 返回是否创建成功

Implementation

static Future<bool> createPath({required String path}) async {
  if (path.isEmpty || kIsWeb) {
    return false;
  }

  try {
    final dir = Directory(path);
    if (!await dir.exists()) {
      await dir.create(recursive: true);
    }
    return true;
  } catch (e) {
    developer.log('创建目录失败: $e');
    return false;
  }
}