loadAsset method
Implementation
Future<void> loadAsset(/*BuildContext context*/) async {
String cipherString = '';
try {
cipherString = await rootBundle.loadString('assets/${enterprise}_config.json');
//jsonString = await DefaultAssetBundle.of(context).loadString('assets/${enterprise}_config.json');
logger.info('assets/${enterprise}_config.json loaded');
} catch (e) {
logger.info('assets/${enterprise}_config.json not exist, hycop_config.json will be used');
try {
cipherString = await rootBundle.loadString('assets/hycop_config.json');
//jsonString = await DefaultAssetBundle.of(context).loadString('assets/hycop_config.json');
logger.info('assets/hycop_config.json loaded');
} catch (e) {
logger.severe('load assets/hycop_config.json failed', e);
return;
}
}
//logger.finest(cipherString);
String jsonString = await MyEncrypt.toDecrypt(cipherString);
//logger.finest(jsonString);
jsonMap = jsonDecode(jsonString);
}