writeContentByFile static method
Implementation
static Future<bool> writeContentByFile({
required File file,
required String content,
bool? autoCreate = false,
FileMode mode = FileMode.append
}) async {
try {
if (autoCreate == true) {
bool fileExists = await file.exists();
if (fileExists == false) {
await file.create(recursive: true);
}
}
await file.writeAsString(
content,
mode: mode,
flush: true,
);
return true;
} catch (e) {
print("writeContentByFile error = $e");
return false;
}
}