deleteFile static method

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

删除文件

path 要删除的文件路径 返回是否删除成功

Implementation

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

  try {
    final file = File(path);
    if (await file.exists()) {
      await file.delete();
      return true;
    }
    return false;
  } catch (e) {
    developer.log('删除文件失败: $e');
    return false;
  }
}