getLanguageList static method
Get language list
Implementation
static Future<List<Map<String, String>>> getLanguageList(
{String langPath = 'lang'}) async {
List<Map<String, String>> list = [];
try {
String assetManifest = await rootBundle.loadString('AssetManifest.json');
List<String> langFiles = jsonDecode(assetManifest)
.keys
.where((String key) => key.contains("lang"))
.toList();
for (var langFile in langFiles) {
RegExp regex = RegExp(langPath + r'/(.*).json');
Match? match = regex.firstMatch(langFile);
if (match == null) continue;
String? extractedString = match.group(1);
if (extractedString == null) continue;
Map<String, String>? langData = getLanguageData(extractedString);
if (langData == null) continue;
list.add(langData);
}
} on Exception catch (e) {
NyLogger.debug(e.toString());
}
return list;
}