positioned method
Returns the svg with x and y values
Implementation
SvgWrapper positioned({double? x, double? y}) {
String newContent = content;
if (x != null) {
if (content.contains(' x="')) {
newContent =
newContent.replaceFirst(RegExp(r' x="[0-9\.\-]+"'), 'x="$x"');
} else {
newContent = newContent.replaceFirst("<svg ", '<svg x="$x" ');
}
}
if (y != null) {
if (content.contains(' y="')) {
newContent =
newContent.replaceFirst(RegExp(r' y="[0-9\.\-]+"'), 'y="$y"');
} else {
newContent = newContent.replaceFirst("<svg ", '<svg y="$y" ');
}
}
return SvgWrapper(name: name, content: newContent);
}