fetchCurrentBundleName function
Implementation
String fetchCurrentBundleName(Context context, String plistFileData) {
final parsed = XmlDocument.parse(plistFileData);
final allKeys = parsed.findAllElements("key");
final allValues = parsed.findAllElements("string").toList();
String? bundleName = null;
allKeys.toList().asMap().forEach((key, val) {
if (val.toString().contains("CFBundleName")) {
bundleName = allValues[key].toString();
}
});
if (bundleName == null) {
throw Exception(
"Bundle name not found in ${context.infoPlistPath}. Info.plist might be corrupt.");
}
return bundleName as String;
}