replaceAssetsBlock static method
void
replaceAssetsBlock()
Implementation
static void replaceAssetsBlock() {
try {
String newAssetsBlock = '''
assets:
- assets/img/
''';
// Read the content of the pubspec.yaml file
File file = File('pubspec.yaml');
String content = file.readAsStringSync();
// Replace the #assets block with the new assets block
content = content.replaceAll(
RegExp(r'#\s*assets:(.*?)(?=#|$)', multiLine: true, dotAll: true),
newAssetsBlock);
// Write the modified content back to the file
file.writeAsStringSync(content);
} catch (e) {
print('Error: $e');
}
}