updateTextThemeStyles static method
Implementation
static Future<void> updateTextThemeStyles(
{required List<String> textStyles, bool verbose = false}) async {
if (verbose) {
print(grey('\tUpdating AppTheme for TextStyles'));
}
final appTheme =
File(join(Directory.current.path, FileConstants.appThemeFile));
if (!await appTheme.exists()) {
throw Exception("AppTheme file does not exist: ${appTheme.path}");
}
final content = appTheme.readAsStringSync();
final newContent = content.replaceAllMapped(
RegExp(r'AppTextThemeExtension\(\n(.*?\n)*?\s*\);'),
(match) => 'AppTextThemeExtension(\n${textStyles.map(
(e) => '\t\t$e: TextStyleConst.$e,\n',
).join()}\t);');
appTheme.writeAsString(newContent);
}