getTextStyles static method

Future<List<String>> getTextStyles({
  1. bool verbose = false,
})

Implementation

static Future<List<String>> getTextStyles({bool verbose = false}) async {
  if (verbose) {
    print(grey('\tGetting text styles: text_style_const.dart'));
  }

  final textStylesConstFile =
      File(join(Directory.current.path, FileConstants.appTextStyleConstFile));

  if (!await textStylesConstFile.exists()) {
    throw Exception("File does not exist: ${textStylesConstFile.path}");
  }

  final content = textStylesConstFile.readAsStringSync();
  final matches = RegExp(r'(\w+) = TextStyle').allMatches(content);
  final List<String> textStyles = [];

  for (var element in matches) {
    final match = element.group(1);
    if (match == null) continue;

    textStyles.add(match);
  }

  return textStyles;
}