generateTextStyles static method
Implementation
static Future<void> generateTextStyles(
{required List<String> textStyles, bool verbose = false}) async {
if (verbose) {
print(grey('\tUpdating AppTextThemeExtension'));
}
final appThemeExtension = Directory(
join(Directory.current.path, FileConstants.appThemeExtensionDirectory));
if (!await appThemeExtension.exists()) {
throw Exception(
"AppTextThemeExtension directory does not exist: ${appThemeExtension.path}");
}
final appTextStylesExtensionFile = File(
join(appThemeExtension.path, FileConstants.appTextStylesExtensionFile));
appTextStylesExtensionFile
.writeAsString(ThemeConstants.generateTextStylesFile(
requiredConstructor:
textStyles.map((e) => '\t\trequired this.$e,').join('\n'),
classDeclaration: textStyles
.map(
(e) => "\tfinal TextStyle $e;",
)
.join('\n'),
copyWithArguments: textStyles
.map(
(e) => '\t\tTextStyle? $e,',
)
.join('\n'),
copyWithReturn:
textStyles.map((e) => '\t\t\t$e: $e ?? this.$e,').join('\n'),
lerpReturn: textStyles
.map((e) => '\t\t\t$e: TextStyle.lerp($e, other.$e, t)!,')
.join('\n'),
));
}