decodeDecorationImage static method
Decodes the given value
to an DecorationImage. This expects the given
value
to follow the structure below:
{
"alignment": <Alignment>,
"centerSlice": <Rect>,
"fit": <BoxFit>,
"image": <ImageProvider>,
"matchTextDirection": <bool>,
"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']) ?? Alignment.center,
centerSlice: decodeRect(value['centerSlice']),
// @unencodable
// colorFilter
fit: decodeBoxFit(value['fit']),
image: decodeImageProvider(value['image'])!,
matchTextDirection: JsonClass.parseBool(value['matchTextDirection']),
repeat: decodeImageRepeat(value['repeat']) ?? ImageRepeat.noRepeat,
scale: JsonClass.parseDouble(value['scale'], 1.0)!,
);
}
return result;
}