build method

XmlElement build()

Builds and returns the XmlElement for this element.

Implementation

XmlElement build() {
  if (null != _element) {
    return _element!;
  }
  final Map<String, String> attrs = Map.from(_attributes);
  attrs['id'] = _id;
  if (_styles.isNotEmpty) attrs['style'] = _stylesToString();
  _element = XmlElement(
    XmlName(_tag),
    [
      ..._attributes.entries.map(
        (e) => XmlAttribute(XmlName(e.key), e.value),
      ),
    ],
    [..._children.map((e) => e.build())],
  );
  return _element!;
}