fromElement static method
XmlElement
fromElement(
- XmlElement element
Converts an svg
element into a vector
element. Translating all the
necessary attributes.
Implementation
static XmlElement fromElement(XmlElement element) {
final newElement = XmlElement(
XmlName('vector'),
[],
element.children.map((child) => child.copy()),
element.isSelfClosing,
)..setAttribute(
'xmlns:android',
'http://schemas.android.com/apk/res/android',
);
final dimensions = _SvgDimension.parse(element);
newElement
..setAttribute(
AttributeName.androidWidth,
'${dimensions.width.toStringAsFixed(0)}dp',
)
..setAttribute(
AttributeName.androidHeight,
'${dimensions.height.toStringAsFixed(0)}dp',
)
..setAttribute(
AttributeName.androidViewportWidth,
dimensions.width.toString(),
)
..setAttribute(
AttributeName.androidViewportHeight,
dimensions.height.toString(),
);
return newElement;
}