fromDynamic static method
Builds the builder from a Map-like dynamic structure. This expects the JSON format to be of the following structure:
{
"alignment": <Alignment>,
"cacheHeight": <int>,
"cacheWidth": <int>,
"centerSlice": <Rect>,
"color": <Color>,
"colorBlendMode": <BlendMode>,
"errorBuilder": <WidgetBuilder>,
"excludeFromSemantics": <bool>,
"filterQuality": <FilterQuality>,
"fit": <BoxFit>,
"frameBuilder": <ImageFrameBuilder>,
"gaplessPlayback": <bool>,
"height": <double>,
"headers": <<Map<String, String>>
"isAntiAlias": <bool>,
"loadingBuilder": <ImageLoadingBuilder>,
"matchTextDirection": <bool>,
"opacity": <double>,
"repeat": <ImageRepeat>,
"scale": <double>,
"semanticLabel": <String>,
"src": <String>,
"width": <double>
}
The "image" attribute can be either a base64 encoded String, or a Uint8List returned via a function or variable reference using the JsonWidgetRegistry.
As a note, the ImageErrorWidgetBuilder, ImageFrameBuilder, and ImageLoadingBuilder cannot be decoded via JSON. Instead, the only way to bind those values to the builder is to use a function or a variable reference via the JsonWidgetRegistry.
See also:
ThemeDecoder.decodeAlignment
ThemeDecoder.decodeBlendMode
ThemeDecoder.decodeColor
ThemeDecoder.decodeImageRepeat
Implementation
static JsonNetworkImageBuilder? fromDynamic(
dynamic map, {
JsonWidgetRegistry? registry,
}) {
JsonNetworkImageBuilder? result;
if (map != null) {
result = JsonNetworkImageBuilder(
alignment: ThemeDecoder.decodeAlignment(
map['alignment'],
validate: false,
) ??
Alignment.center,
cacheHeight: JsonClass.parseInt(map['cacheHeight']),
cacheWidth: JsonClass.parseInt(map['cacheWidth']),
centerSlice: ThemeDecoder.decodeRect(
map['centerSlice'],
validate: false,
),
color: ThemeDecoder.decodeColor(
map['color'],
validate: false,
),
colorBlendMode: ThemeDecoder.decodeBlendMode(
map['colorBlendMode'],
validate: false,
),
errorBuilder: map['errorBuilder'],
excludeFromSemantics: JsonClass.parseBool(map['excludeFromSemantics']),
filterQuality: ThemeDecoder.decodeFilterQuality(
map['filterQuality'],
validate: false,
) ??
FilterQuality.low,
fit: ThemeDecoder.decodeBoxFit(
map['fit'],
validate: false,
),
frameBuilder: map['frameBuilder'],
gaplessPlayback: JsonClass.parseBool(map['gaplessPlayback']),
height: JsonClass.parseDouble(map['height']),
headers: map['headers'] == null
? null
: Map<String, String>.from(map['headers']),
isAntiAlias: JsonClass.parseBool(map['isAntiAlias']),
loadingBuilder: map['loadingBuilder'],
matchTextDirection: JsonClass.parseBool(map['matchTextDirection']),
opacity: JsonClass.parseDouble(map['opacity']),
repeat: ThemeDecoder.decodeImageRepeat(
map['imageRepeat'],
validate: false,
) ??
ImageRepeat.noRepeat,
scale: JsonClass.parseDouble(map['scale'], 1.0)!,
semanticLabel: map['semanticLabel'],
src: map['src'],
width: JsonClass.parseDouble(map['width']),
);
}
return result;
}