CustomSvg.memory constructor

CustomSvg.memory(
  1. Uint8List bytes, {
  2. Key? key,
  3. double? width,
  4. double? height,
  5. BoxFit fit = BoxFit.contain,
  6. AlignmentGeometry alignment = Alignment.center,
  7. bool matchTextDirection = false,
  8. bool allowDrawingOutsideViewBox = false,
  9. WidgetBuilder? placeholderBuilder,
  10. ColorFilter? colorFilter,
  11. @Deprecated('This parameter is deprecated and is no longer implemented.') Color? color,
  12. @Deprecated('This parameter is deprecated and is no longer implemented.') BlendMode colorBlendMode = ui.BlendMode.srcIn,
  13. String? semanticsLabel,
  14. bool excludeFromSemantics = false,
  15. Clip clipBehavior = Clip.hardEdge,
  16. SvgTheme? theme,
  17. @Deprecated('This parameter is deprecated and is no longer implemented.') bool cacheColorFilter = false,
})

Creates a widget that displays an SVG obtained from a Uint8List.

The bytes argument must not be null.

Either the width and height arguments should be specified, or the widget should be placed in a context that sets tight layout constraints. Otherwise, the image dimensions will change as the image is loaded, which will result in ugly layout changes.

If matchTextDirection is set to true, the picture will be flipped horizontally in TextDirection.rtl contexts.

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.

A custom placeholderBuilder can be specified for cases where decoding or acquiring data may take a noticeably long time.

The color and colorBlendMode arguments, if specified, will be used to set a ColorFilter on any Paints created for this drawing.

The theme argument, if provided, will override the default theme used when parsing SVG elements.

If excludeFromSemantics is true, then semanticsLabel will be ignored.

Implementation

CustomSvg.memory(
  Uint8List bytes, {
  Key? key,
  this.width,
  this.height,
  this.fit = BoxFit.contain,
  this.alignment = Alignment.center,
  this.matchTextDirection = false,
  this.allowDrawingOutsideViewBox = false,
  this.placeholderBuilder,
  ui.ColorFilter? colorFilter,
  @Deprecated('This parameter is deprecated and is no longer implemented.')
  ui.Color? color,
  @Deprecated('This parameter is deprecated and is no longer implemented.')
  ui.BlendMode colorBlendMode = ui.BlendMode.srcIn,
  this.semanticsLabel,
  this.excludeFromSemantics = false,
  this.clipBehavior = Clip.hardEdge,
  SvgTheme? theme,
  @Deprecated('This parameter is deprecated and is no longer implemented.')
  bool cacheColorFilter = false,
})  : bytesLoader = SvgBytesLoader(bytes, theme: theme),
      colorFilter = colorFilter ?? _getColorFilter(color, colorBlendMode),
      super(key: key);