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>",
"isAntiAlias": "<bool>",
"matchTextDirection": "<bool>",
"name": "<String>",
"opacity": "<double>",
"package": "<String>",
"repeat": "<ImageRepeat>",
"scale": "<double>",
"semanticLabel": "<String>",
"width": "<double>"
}
As a note, the ImageErrorWidgetBuilder and ImageFrameBuilder 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 JsonAssetImageBuilder? fromDynamic(
dynamic map, {
JsonWidgetRegistry? registry,
}) {
JsonAssetImageBuilder? result;
if (map != null) {
result = JsonAssetImageBuilder(
alignment: ThemeDecoder.decodeAlignment(
map['alignment'],
validate: false,
) ??
Alignment.center,
cacheHeight: JsonClass.maybeParseInt(map['cacheHeight']),
cacheWidth: JsonClass.maybeParseInt(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.maybeParseDouble(map['height']),
isAntiAlias: JsonClass.parseBool(map['isAntiAlias']),
matchTextDirection: JsonClass.parseBool(map['matchTextDirection']),
name: map['name'],
package: map['package'],
repeat: ThemeDecoder.decodeImageRepeat(
map['imageRepeat'],
validate: false,
) ??
ImageRepeat.noRepeat,
scale: JsonClass.maybeParseDouble(map['scale']),
semanticLabel: map['semanticLabel'],
width: JsonClass.maybeParseDouble(map['width']),
);
}
return result;
}