decodeCornerStrategy static method
Decodes the object from an int or Map-like dynamic structure. This expects the JSON format to be of the following structure:
{
"type": "none"
}
{
"radius": <int>,
"type": "const"
}
Implementation
static charts.CornerStrategy? decodeCornerStrategy(
dynamic map, {
bool validate = true,
}) {
charts.CornerStrategy? result;
if (map is charts.CornerStrategy) {
result = map;
} else if (map is num) {
result = charts.ConstCornerStrategy(map.toInt());
} else if (map != null) {
assert(SchemaValidator.validate(
schemaId: '$_baseSchemaUrl/corner_strategy',
value: map,
validate: validate,
));
final type = map['type'];
switch (type) {
case 'const':
result =
charts.ConstCornerStrategy(JsonClass.parseInt(map['radius'])!);
break;
case 'none':
result = const charts.NoCornerStrategy();
break;
default:
throw Exception('Unknown [CornerStrategy.type] encountered: [$type]');
}
}
return result;
}