fileUpdate function
Implementation
Future<void> fileUpdate(String destinationPath, List<String> apiResponseImport,
List<String> dataSourceAppendLines,
[bool isAppendEOF = false]) async {
if (doesFileExist(destinationPath)) {
try {
if (apiResponseImport.isNotEmpty) {
await addImport(destinationPath, apiResponseImport);
}
if (isAppendEOF) {
await appendLinesToFile(destinationPath, dataSourceAppendLines);
} else {
await findAndReplace(destinationPath, '{}', '{\n}');
await addCodeAboveBraces(destinationPath, dataSourceAppendLines);
}
} catch (e) {
print('Error: $e');
}
} else {
print('File at $destinationPath not exists');
}
}