writeTo method
Write the asset content to the specified file, or the targetPath if
null, optionally setting permissions specified in chmod. If the file
exists and noClobber is true, specified permissions will still be set
but the file won't be overwritten.
Implementation
bool writeTo({File? file, String? chmod, bool noClobber = false}) {
final safeFile = file ?? File(targetPath);
if (!safeFile.parent.existsSync()) {
safeFile.parent.createSync(recursive: true);
}
if (!noClobber || !safeFile.existsSync()) {
safeFile.writeAsStringSync(_contents);
}
if (chmod != null) {
Utils.chmod(chmod, safeFile.path);
}
return safeFile.existsSync();
}