useToMobjects method

List<VMobject> useToMobjects(
  1. Element useElement,
  2. SVGElementStyle style
)

Implementation

List<VMobject> useToMobjects(Element useElement, SVGElementStyle style) {
  //! I don't know why it doesn't work
  // var ref = useElement.attributes['xlink:href'];

  // Temporary fix
  var attributes = useElement.attributes;
  var keys = attributes.keys.toList();
  var values = attributes.values.toList();

  var k = keys.indexWhere((element) =>
      element.toString().contains('href') &&
      element.toString().contains('xlink'));

  var ref = k >= 0 ? values[k] : null;
  // End of fix

  ref = withoutFirst(ref?.split('#') ?? []).join('');

  if (!refToElement.containsKey(ref)) {
    print('SVG ref $ref not recognized');
  }

  return getMobjectsFrom(
      refToElement[ref]!, style.update(getElementStyle(useElement)));
}