parseFileSync method

Map parseFileSync(
  1. String path, {
  2. dynamic typeDetection = true,
})

Synchronously 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

Map parseFileSync(String path, {typeDetection = true}) {
  var file = File(path);
  if (!file.existsSync()) {
    throw NotFoundException('Not found plist file');
  }

  var dataBytes = file.readAsBytesSync();
  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);
  }
}