createFileSync static method
Creates a file at the specified path if it does not exist, and will truncate it if it does. The target directory must exist.
Implementation
static Result<File, IoError> createFileSync(Path path) {
return Fs.ioGuardSync(() {
final file = File(path.asString());
if (file.existsSync()) {
file.writeAsBytesSync([]);
return file;
} else {
file.createSync(recursive: false, exclusive: false);
return file;
}
});
}