parse method
Parses tree
for build ops and text styles.
Implementation
@override
void parse(BuildMetadata meta) {
switch (meta.element.localName) {
case kTagSvg:
meta.register(
_tagSvg ??= BuildOp(
// TODO: set debugLabel when our minimum core version >= 1.0
defaultStyles: (element) {
// other tags that share the same logic:
// - IFRAME
// - IMG
//
// consider update them together if this changes
final attrs = element.attributes;
final height = attrs[kAttributeSvgHeight];
final width = attrs[kAttributeSvgWidth];
return {
'height': 'auto',
'min-width': '0px',
'min-height': '0px',
'width': 'auto',
if (height != null) 'height': height,
if (width != null) 'width': width,
};
},
onWidgets: (meta, widgets) {
final bytesLoader = SvgStringLoader(meta.element.outerHtml);
const src = ImageSource('');
final built = _buildSvgPicture(meta, src, bytesLoader);
return [built];
},
),
);
break;
}
return super.parse(meta);
}