svgPictureStringDecoder method

Future<PictureInfo> svgPictureStringDecoder(
  1. String raw,
  2. bool allowDrawingOutsideOfViewBox,
  3. ColorFilter? colorFilter,
  4. String key, {
  5. 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 theme argument, if provided, will override the default theme used when parsing SVG elements.

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 svgRoot = await fromSvgString(raw, key, theme: theme);
  final Picture pic = svgRoot.toPicture(
    clipToViewBox: allowDrawingOutsideOfViewBox == true ? false : true,
    colorFilter: colorFilter,
    size: svgRoot.viewport.viewBox,
  );
  return PictureInfo(
    picture: pic,
    viewport: svgRoot.viewport.viewBoxRect,
    size: svgRoot.viewport.size,
    compatibilityTester: svgRoot.compatibilityTester,
  );
}