getListByName method
Implementation
Future<List<PrivacyListItem>> getListByName(String name) {
if (!isPrivacyListsSupported()) {
return Future.error(Exception(feature_not_supported_error));
}
var completer = Completer<List<PrivacyListItem>>();
var iqStanza = IqStanza(AbstractStanza.getRandomId(), IqStanzaType.GET)
..fromJid = _connection.fullJid;
var queryStanza = QueryElement();
queryStanza.setXmlns('jabber:iq:privacy');
queryStanza.addChild(ListElement(name));
iqStanza.addChild(queryStanza);
_unrespondedStanzas[iqStanza.id!] = Tuple2((resultStanza) {
var result = <PrivacyListItem>[];
var queryElement = resultStanza.getChild('query');
queryElement?.children.first.children.forEach((listElement) {
result.add(PrivacyListItemElement.fromXml(listElement).item);
});
return result;
}, completer);
_connection.writeStanza(iqStanza);
return completer.future;
}