ResponsiveImage.network constructor
- String src, {
- Key? key,
- double scale = 1.0,
- dynamic frameBuilder,
- dynamic loadingBuilder,
- dynamic errorBuilder,
- dynamic semanticLabel,
- dynamic excludeFromSemantics = false,
- dynamic width,
- dynamic height,
- dynamic color,
- dynamic opacity,
- dynamic colorBlendMode,
- dynamic fit,
- dynamic alignment = Alignment.center,
- dynamic repeat = ImageRepeat.noRepeat,
- dynamic centerSlice,
- dynamic matchTextDirection = false,
- dynamic gaplessPlayback = false,
- dynamic filterQuality = FilterQuality.low,
- dynamic isAntiAlias = false,
- Map<
String, String> ? headers, - int? cacheWidth,
- int? cacheHeight,
- double scaleWatch = 0.1,
- double scaleSmallPhone = 1.0,
- double scaleMediumPhone = 1.0,
- double scaleLargePhone = 1.5,
- double scaleSmallTablet = 1.8,
- double scaleMediumTablet = 2.0,
- double scaleLargeTablet = 2.5,
- double scaleMediumDesktop = 3.0,
- double scaleLargeDesktop = 3.6,
- double scaleTelevision = 4.2,
Creates a widget that displays an ImageStream obtained from the network.
The src, scale, and repeat arguments 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.
All network images are cached regardless of HTTP headers.
An optional headers argument can be used to send custom HTTP headers
with the image request.
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 should 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.
In the case where the network image is on the Web platform, the cacheWidth
and cacheHeight parameters are ignored as the web engine delegates
image decoding to the web which does not support custom decode sizes.
Implementation
//
// TODO(garyq): We should eventually support custom decoding of network images
// on Web as well, see https://github.com/flutter/flutter/issues/42789.
ResponsiveImage.network(
String src, {
Key? key,
double scale = 1.0,
frameBuilder,
loadingBuilder,
errorBuilder,
semanticLabel,
excludeFromSemantics = false,
width,
height,
color,
opacity,
colorBlendMode,
fit,
alignment = Alignment.center,
repeat = ImageRepeat.noRepeat,
centerSlice,
matchTextDirection = false,
gaplessPlayback = false,
filterQuality = FilterQuality.low,
isAntiAlias = false,
Map<String, String>? headers,
int? cacheWidth,
int? cacheHeight,
double scaleWatch = 0.1,
double scaleSmallPhone = 1.0,
double scaleMediumPhone = 1.0,
double scaleLargePhone = 1.5,
double scaleSmallTablet = 1.8,
double scaleMediumTablet = 2.0,
double scaleLargeTablet = 2.5,
double scaleMediumDesktop = 3.0,
double scaleLargeDesktop = 3.6,
double scaleTelevision = 4.2,
}) : super(
scaleWatch: scaleWatch,
scaleSmallPhone: scaleSmallPhone,
scaleMediumPhone: scaleMediumPhone,
scaleLargePhone: scaleLargePhone,
scaleSmallTablet: scaleSmallTablet,
scaleMediumTablet: scaleMediumTablet,
scaleLargeTablet: scaleLargeTablet,
scaleMediumDesktop: scaleMediumDesktop,
scaleLargeDesktop: scaleLargeDesktop,
scaleTelevision: scaleTelevision
) {
set('key', key)
.set('imageType', _ImageType.networkImage)
.set('frameBuilder', frameBuilder)
.set('loadingBuilder', loadingBuilder)
.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);
}