addToConfig static method
dynamic
addToConfig({})
Attempts to replace a file. Provide a configName
to select which file to replace.
Then you can use the callback originalFile
to get the file and manipulate it.
Implementation
static addToConfig(
{required String configName,
required String classImport,
required String Function(String originalFile) createTemplate}) async {
// add it to the decoder config
String filePath = "lib/config/$configName.dart";
String originalFile = await loadAsset(filePath);
// create new file
String fileCreated = createTemplate(originalFile);
if (fileCreated == "") {
return;
}
// Add import
fileCreated = classImport + "\n" + fileCreated;
// save new file
final File file = File(filePath);
await file.writeAsString(fileCreated);
}