decodeTextStyleSpec static method
Decodes the object from a Map-like dynamic structure. This expects the JSON format to be of the following structure:
{
"color": <Color>,
"fontFamily": <String>,
"fontSize": <int>,
"fontWeight": <String>,
"lineHeight": <double>
}
See also
Implementation
static charts.TextStyleSpec? decodeTextStyleSpec(
dynamic map, {
bool validate = true,
}) {
charts.TextStyleSpec? result;
if (map is charts.TextStyleSpec) {
result = map;
} else if (map != null) {
assert(SchemaValidator.validate(
schemaId: '$_baseSchemaUrl/text_style_spec',
value: map,
validate: validate,
));
result = charts.TextStyleSpec(
color: decodeColor(map['color']),
fontFamily: map['fontFamily']?.toString(),
fontSize: JsonClass.parseInt(map['fontSize']),
fontWeight: map['fontWeight']?.toString(),
lineHeight: JsonClass.parseDouble(map['lineHeight']),
);
}
return result;
}