svgPictureDecoder method

Future<PictureInfo> svgPictureDecoder(
  1. Uint8List raw,
  2. bool allowDrawingOutsideOfViewBox,
  3. ColorFilter? colorFilter,
  4. String key, {
  5. SvgTheme theme = const SvgTheme(),
})

Produces a PictureInfo from a Uint8List of SVG byte data (assumes UTF8 encoding).

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> svgPictureDecoder(
  Uint8List raw,
  bool allowDrawingOutsideOfViewBox,
  ColorFilter? colorFilter,
  String key, {
  SvgTheme theme = const SvgTheme(),
}) async {
  final DrawableRoot svgRoot = await fromSvgBytes(raw, key, theme: theme);
  final Picture pic = svgRoot.toPicture(
    clipToViewBox: allowDrawingOutsideOfViewBox == true ? false : true,
    colorFilter: colorFilter,
  );
  return PictureInfo(
    picture: pic,
    viewport: svgRoot.viewport.viewBoxRect,
    size: svgRoot.viewport.size,
    compatibilityTester: svgRoot.compatibilityTester,
  );
}