getI18nKeysFromFile function

Map<String, String> getI18nKeysFromFile(
  1. File file
)

Implementation

Map<String, String> getI18nKeysFromFile(File file) {
  final regex = RegExp(r'''[\'\'](.*)[\'\'].i18n\(.*\).*\/\/(.*)''');
  final response = <String, String>{};
  var data = file.readAsStringSync();
  if (regex.hasMatch(data)) {
    regex
        .allMatches(data)
        .forEach((match) => response[match.group(1)!] = match.group(2)!);
  }

  return response;
}