decodeDecorationImage static method
Decodes the given value
to an DecorationImage. This expects the given
value
to follow the structure below:
{
"alignment": <Alignment>,
"centerSlice": <Rect>,
"filterQuality": <FilterQuality>,
"fit": <BoxFit>,
"image": <ImageProvider>,
"invertColors": <bool>,
"isAntiAlias": <bool>,
"matchTextDirection": <bool>,
"opacity": <double>,
"repeat": <ImageRepeat>,
"scale": <double>
}
See also:
Implementation
static DecorationImage? decodeDecorationImage(
dynamic value, {
bool validate = true,
}) {
DecorationImage? result;
if (value is DecorationImage) {
result = value;
} else if (value != null) {
assert(SchemaValidator.validate(
schemaId: '$_baseSchemaUrl/decoration_image',
value: value,
validate: validate,
));
result = DecorationImage(
alignment: decodeAlignment(
value['alignment'],
validate: false,
) ??
Alignment.center,
centerSlice: decodeRect(
value['centerSlice'],
validate: false,
),
// @unencodable
// colorFilter
// @unencodable
// onError
fit: decodeBoxFit(
value['fit'],
validate: false,
),
filterQuality: decodeFilterQuality(
value['filterQuality'],
validate: false,
) ??
FilterQuality.low,
image: decodeImageProvider(
value['image'],
validate: false,
)!,
invertColors: JsonClass.parseBool(value['invertColors']),
isAntiAlias: JsonClass.parseBool(value['isAntiAlias']),
matchTextDirection: JsonClass.parseBool(value['matchTextDirection']),
opacity: JsonClass.parseDouble(value['opacity']) ?? 1.0,
repeat: decodeImageRepeat(
value['repeat'],
validate: false,
) ??
ImageRepeat.noRepeat,
scale: JsonClass.parseDouble(value['scale'], 1.0)!,
);
}
return result;
}