fromSvgString static method
Parse an SVG XML string to a scalable image
If compact
is true, the internal representation will occupy
significantly less memory, at the expense of rendering time. See
toDag for a discussion of the two representations.
If bigFloats
is true, the compact representation
will use 8 byte double-precision float values, rather than 4 byte
single-precision values.
If warnF
is non-null, it will be called if the SVG asset contains
unrecognized tags and/or tag attributes. If it is null, the default
behavior is to print warnings.
See also ScalableImage.currentColor.
Implementation
static ScalableImage fromSvgString(String src,
{bool compact = false,
bool bigFloats = false,
@Deprecated("[warn] has been superseded by [warnF].") bool warn = true,
void Function(String)? warnF,
Color? currentColor}) {
final warnArg = warnF ?? (warn ? defaultWarn : nullWarn);
if (compact) {
final b = SICompactBuilder(
warn: warnArg, currentColor: currentColor, bigFloats: bigFloats);
StringSvgParser(src, b, warn: warnArg).parse();
return b.si;
} else {
final b = SIDagBuilder(warn: warnArg, currentColor: currentColor);
StringSvgParser(src, b, warn: warnArg).parse();
return b.si;
}
}