writeFile static method
Implementation
static Future<bool> writeFile(String? filepath, dynamic content) async {
bool ok = true;
if (filepath == null) return false;
try {
// create the folder
String? folder = await createFolder(filepath);
// write the file
if (folder != null) {
if (content is ByteData) {
await File(filepath).writeAsBytes(content.buffer.asUint8List());
}
if (content is Uint8List) await File(filepath).writeAsBytes(content);
if (content is String) await File(filepath).writeAsString(content);
}
} catch (e) {
Log().exception(e,
caller: 'platform.vm.dart => bool fileWriteBytes($filepath)');
ok = false;
}
return ok;
}