ResponsiveImage.memory constructor

ResponsiveImage.memory(
  1. Uint8List bytes, {
  2. Key? key,
  3. double scale = 1.0,
  4. dynamic frameBuilder,
  5. dynamic errorBuilder,
  6. dynamic semanticLabel,
  7. dynamic excludeFromSemantics = false,
  8. dynamic width,
  9. dynamic height,
  10. dynamic color,
  11. dynamic opacity,
  12. dynamic colorBlendMode,
  13. dynamic fit,
  14. dynamic alignment = Alignment.center,
  15. dynamic repeat = ImageRepeat.noRepeat,
  16. dynamic centerSlice,
  17. dynamic matchTextDirection = false,
  18. dynamic gaplessPlayback = false,
  19. dynamic isAntiAlias = false,
  20. dynamic filterQuality = FilterQuality.low,
  21. int? cacheWidth,
  22. int? cacheHeight,
})

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

The bytes argument specifies encoded image bytes, which can be encoded in any of the following supported image formats:

The scale argument specifies the linear scale factor for drawing this image at its intended size and applies to both the width and the height. For example, if this is 2.0, it means that there are four image pixels for every one logical pixel, and the image's actual width and height (as given by the dart:ui.Image.width and dart:ui.Image.height properties) are double the height and width that should be used when painting the image (e.g. in the arguments given to Canvas.drawImage).

The bytes, scale, and repeat arguments must not be null.

This only accepts compressed image formats (e.g. PNG). Uncompressed formats like rawRgba (the default format of dart:ui.Image.toByteData) will lead to exceptions.

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.

Use filterQuality to specify the rendering quality of the image.

If excludeFromSemantics is true, then semanticLabel will be ignored.

If cacheWidth or cacheHeight are provided, it indicates to the engine that the image must be decoded at the specified size. The image will be rendered to the constraints of the layout or width and height regardless of these parameters. These parameters are primarily intended to reduce the memory usage of ImageCache.

Implementation

ResponsiveImage.memory(
  Uint8List bytes, {
  Key? key,
  double scale = 1.0,
  frameBuilder,
  errorBuilder,
  semanticLabel,
  excludeFromSemantics = false,
  width,
  height,
  color,
  opacity,
  colorBlendMode,
  fit,
  alignment = Alignment.center,
  repeat = ImageRepeat.noRepeat,
  centerSlice,
  matchTextDirection = false,
  gaplessPlayback = false,
  isAntiAlias = false,
  filterQuality = FilterQuality.low,
  int? cacheWidth,
  int? cacheHeight,
}) : super() {

  set('key', key)
  .set('imageType', _ImageType.memoryImage)
  .set('bytes', bytes)
  .set('scale', scale)
  .set('frameBuilder', frameBuilder)
  .set('errorBuilder', errorBuilder)
  .set('semanticLabel', semanticLabel)
  .set('excludeFromSemantics', excludeFromSemantics)
  .set('width', width)
  .set('height', height)
  .set('color', color)
  .set('opacity', opacity)
  .set('colorBlendMode', colorBlendMode)
  .set('fit', fit)
  .set('alignment', alignment)
  .set('repeat', repeat)
  .set('centerSlice', centerSlice)
  .set('matchTextDirection', matchTextDirection)
  .set('gaplessPlayback', gaplessPlayback)
  .set('isAntiAlias', isAntiAlias)
  .set('filterQuality', filterQuality)
  .set('cacheWidth', cacheWidth)
  .set('cacheHeight', cacheHeight);

}