propertyListWithData static method

Object propertyListWithData(
  1. ByteData data, {
  2. bool keyedArchive = false,
})

Creates and returns an object graph from the specified property list binary ByteData. Equivalent to iOS method [NSPropertyList propertyListWithData:options:format:error]

The data parameter must be a ByteData of binary plist.

If keyedArchive parameter is true, then CF$UID constructs are also decoded into UID objects. If false, then a PropertyListReadStreamException is thrown if a CF$UID construct is encountered.

Returns one of String, int, double, Map<String, Object>, List, DateTime, bool, ByteData or UID.

Hint: To convert any returned ByteData objects into a Uint8List, you should use the following pattern:

data.buffer.asUint8List(data.offsetInBytes, data.lengthInBytes);

Throws PropertyListReadStreamException if the plist is corrupt, values could not be converted or the input stream is EOF.

Implementation

static Object propertyListWithData(
  ByteData data, {
  bool keyedArchive = false,
}) {
  try {
    final p = BinaryPropertyListReader(data, keyedArchive: keyedArchive);
    return p.parse();
  } catch (e, s) {
    if (e is PropertyListReadStreamException) {
      rethrow;
    } else {
      print(s);
      throw PropertyListReadStreamException.nested(e);
    }
  }
}