decodeLayoutConfig static method
Decodes the object from an int or Map-like dynamic structure. This expects the JSON format to be of the following structure:
{
"bottomMarginSpec": <MarginSpec>,
"leftMarginSpec": <MarginSpec>,
"rightMarginSpec": <MarginSpec>,
"topMarginSpec": <MarginSpec>
}
Implementation
static charts.LayoutConfig? decodeLayoutConfig(
dynamic map, {
bool validate = true,
}) {
charts.LayoutConfig? result;
if (map is charts.LayoutConfig) {
result = map;
} else if ((map is num || map is String) &&
JsonClass.parseInt(map) != null) {
result = charts.LayoutConfig(
bottomMarginSpec: decodeMarginSpec(
map,
validate: false,
)!,
leftMarginSpec: decodeMarginSpec(
map,
validate: false,
)!,
rightMarginSpec: decodeMarginSpec(
map,
validate: false,
)!,
topMarginSpec: decodeMarginSpec(
map,
validate: false,
)!,
);
} else if (map != null) {
assert(SchemaValidator.validate(
schemaId: '$_baseSchemaUrl/layout_config',
value: map,
validate: validate,
));
result = charts.LayoutConfig(
bottomMarginSpec: decodeMarginSpec(
map['bottomMarginSpec'],
validate: false,
) ??
charts.MarginSpec.fixedPixel(0),
leftMarginSpec: decodeMarginSpec(
map['leftMarginSpec'],
validate: false,
) ??
charts.MarginSpec.fixedPixel(0),
rightMarginSpec: decodeMarginSpec(
map['rightMarginSpec'],
validate: false,
) ??
charts.MarginSpec.fixedPixel(0),
topMarginSpec: decodeMarginSpec(
map['topMarginSpec'],
validate: false,
) ??
charts.MarginSpec.fixedPixel(0),
);
}
return result;
}