writeToFile method
将文本内容写入指定文件目录中
filePath 文件路径
Implementation
bool writeToFile(String filePath) {
try {
final file = File(filePath);
// 确保目录存在
file.parent.createSync(recursive: true);
// 写入字符串内容
file.writeAsStringSync(this);
return true;
} catch (e) {
Logger.log('Error writing to file: $e');
return false;
}
}