svgPictureStringDecoder method
Future<PictureInfo>
svgPictureStringDecoder(
- String raw,
- bool allowDrawingOutsideOfViewBox,
- ColorFilter? colorFilter,
- String key, {
- SvgTheme theme = const SvgTheme(),
Produces a PictureInfo from a String of SVG data.
The allowDrawingOutsideOfViewBox
parameter should be used with caution -
if set to true, it will not clip the canvas used internally to the view box,
meaning the picture may draw beyond the intended area and lead to undefined
behavior or additional memory overhead.
The colorFilter
property will be applied to any Paint objects used during drawing.
The key
will be used for debugging purposes.
Implementation
Future<PictureInfo> svgPictureStringDecoder(
String raw,
bool allowDrawingOutsideOfViewBox,
ColorFilter? colorFilter,
String key, {
SvgTheme theme = const SvgTheme(),
}) async {
final DrawableRoot svg = await fromSvgString(raw, key, theme: theme);
return PictureInfo(
picture: svg.toPicture(
clipToViewBox: allowDrawingOutsideOfViewBox == true ? false : true,
colorFilter: colorFilter,
size: svg.viewport.viewBox,
),
viewport: svg.viewport.viewBoxRect,
size: svg.viewport.size,
);
}