loadFile method
Load a JSON file from the asset bundle and parse it into a map.
Implementation
Future<Map<String, dynamic>> loadFile(Locale locale) async {
try {
final text = await assetBundle.loadString('$assetPath/$langTag.json');
return json.decode(text);
} catch (e) {
debugPrint(e.toString());
}
// load only language code
if (langTag != locale.languageCode) {
langTag = locale.languageCode;
try {
final text = await assetBundle.loadString('$assetPath/$langTag.json');
return json.decode(text);
} catch (e) {
debugPrint(e.toString());
}
}
// return empty map
return {};
}