toXml method

XMLNode toXml()

Implementation

XMLNode toXml() {
  return XMLNode(
    tag: 'field',
    attributes: <String, dynamic>{
      if (varAttr != null) 'var': varAttr,
      if (type != null) 'type': type,
      if (label != null) 'label': label,
    },
    children: [
      if (description != null)
        XMLNode(
          tag: 'desc',
          text: description,
        ),
      if (isRequired)
        XMLNode(
          tag: 'required',
        ),
      ...values.map((value) => XMLNode(tag: 'value', text: value)),
      ...options.map((option) => option.toXml()),
    ],
  );
}