readFile static method
读取文件内容
Reads the content of a file
Implementation
static FileResult<String> readFile(String path) {
try {
final file = File(path);
if (!file.existsSync()) {
return const FileResult.failure('File does not exist');
}
final content = file.readAsStringSync();
return FileResult.success(content);
} catch (e, stack) {
loge('Failed to read file $path: $e\n$stack');
return FileResult.failure(e.toString());
}
}