buildErrorElement function

XMLNode buildErrorElement(
  1. String type,
  2. String condition,
  3. {String? text}
)

Build an element with a child <condition type="type" />. If text is not null, then the condition element will contain a element with text as the body.

Implementation

XMLNode buildErrorElement(String type, String condition, {String? text}) {
  return XMLNode(
    tag: 'error',
    attributes: <String, dynamic>{'type': type},
    children: [
      XMLNode.xmlns(
        tag: condition,
        xmlns: fullStanzaXmlns,
        children: [
          if (text != null)
            XMLNode.xmlns(
              tag: 'text',
              xmlns: fullStanzaXmlns,
              text: text,
            ),
        ],
      ),
    ],
  );
}