build method
XmlDocument
build()
Builds the XmlDocument representing the SVG.
This method constructs the root <svg> element, adds metadata,
and iterates through all added elements to build the final document.
Implementation
XmlDocument build() {
if (null != _document) return _document!;
_builder.processing(
'xml',
'version="1.0" encoding="UTF-8" standalone="no"',
);
_builder.element(
'svg',
attributes: {
'version': '1.1',
'id': 'svg1',
'width': '${_size.width}',
'height': '${_size.height}',
'viewBox': '0 0 ${_size.width} ${_size.height}',
'xmlns': 'http://www.w3.org/2000/svg',
'xmlns:svg': 'http://www.w3.org/2000/svg',
},
nest: () {
_builder.element('defs', attributes: {'id': 'defs1'});
for (final element in _elements) {
element._forBuilder(_builder);
}
},
);
_document = _builder.buildDocument();
return _document!;
}