parseFile method
Return an Map object for the given the path of plist format file. It detects if file format is binary or xml automatically.
Set "typeDetection = false" when you force to use the xml parser.
Implementation
Future<Map> parseFile(String path, {typeDetection = true}) async {
var file = File(path);
if (!await file.exists()) {
throw NotFoundException('Not found plist file');
}
return file.readAsBytes().then((dataBytes) {
if (typeDetection && isBinaryTypeBytes(dataBytes)) {
return parseBinaryBytes(dataBytes);
} else {
var xml = '';
try {
xml = utf8.decode(String.fromCharCodes(dataBytes).runes.toList());
} on Exception catch (e) {
throw XmlParserException('Invalid data format. $e');
}
return parseXml(xml);
}
});
}