SvgClipPath.fromXml constructor
SvgClipPath.fromXml(
- XmlElement element,
- SvgPainter painter,
- SvgBrush brush
Implementation
factory SvgClipPath.fromXml(
XmlElement element, SvgPainter painter, SvgBrush brush) {
final clipPathAttr = element.getAttribute('clip-path');
if (clipPathAttr == null) {
return const SvgClipPath(null, true, null);
}
Iterable<SvgOperation?> children;
if (clipPathAttr.startsWith('url(#')) {
final id = clipPathAttr.substring(5, clipPathAttr.lastIndexOf(')'));
final clipPath = painter.parser.findById(id);
if (clipPath != null) {
children = clipPath.children
.whereType<XmlElement>()
.map<SvgOperation?>((c) => SvgOperation.fromXml(c, painter, brush));
return SvgClipPath(children, false, painter);
}
}
return const SvgClipPath(null, true, null);
}