loadArbFiles static method

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

Implementation

static Future<List<String>> loadArbFiles(
  String arbDirectory, {
  bool verbose = false,
}) async {
  final Directory directory =
      Directory(join(Directory.current.path, arbDirectory));

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

  final Set<String> result = {};
  await for (var entity in directory.list(recursive: false)) {
    if (entity is File && entity.path.endsWith(FileConstants.arbFormat)) {
      if (verbose) {
        print(grey('\tLoading: ${entity.path}'));
      }

      final arb = jsonDecode(File(entity.path).readAsStringSync())
          as Map<String, dynamic>;

      result.addAll((arb.keys.toList()
        ..removeWhere(
          (element) => element.startsWith('@'),
        )));
    }
  }

  return result.toList();
}