toXml method
must only be called to save this object.
Implementation
@override
xml.XmlElement toXml() {
final ret = super.toXml()..replaceSingle(customData.toXml());
XmlUtils.removeChildrenByName(ret, KdbxXml.NODE_BINARIES);
// with kdbx >= 4 we assume the binaries were already written in the header.
if (ctx.versionMajor < 4) {
ret.children.add(
XmlElement(XmlName(KdbxXml.NODE_BINARIES))
..children.addAll(
enumerate(ctx.binariesIterable).map((indexed) {
final xmlBinary = XmlUtils.createNode(KdbxXml.NODE_BINARY)
..addAttribute(KdbxXml.ATTR_ID, indexed.index.toString());
indexed.value.saveToXml(xmlBinary);
return xmlBinary;
}),
),
);
}
XmlUtils.removeChildrenByName(ret, KdbxXml.NODE_CUSTOM_ICONS);
ret.children.add(
XmlElement(XmlName(KdbxXml.NODE_CUSTOM_ICONS))
..children.addAll(customIcons.values.map(
(e) => XmlUtils.createNode(KdbxXml.NODE_ICON, [
XmlUtils.createTextNode(KdbxXml.NODE_UUID, e.uuid.uuid),
XmlUtils.createTextNode(KdbxXml.NODE_DATA, base64.encode(e.data))
]),
)),
);
return ret;
}