writeFileIfMissing method
Writes contents to filePath only when the file does not exist.
Returns true when written, false when skipped.
Implementation
bool writeFileIfMissing({
required String filePath,
required String contents,
}) {
final file = File(filePath);
if (file.existsSync()) {
return false;
}
file.parent.createSync(recursive: true);
file.writeAsStringSync(contents);
return true;
}