decodeMaxWidthStrategy static method
Expects the map
to be either a common.MaxWidthStrategy
or a
String containing one of the following values:
ellipsize
truncate
Implementation
static common.MaxWidthStrategy? decodeMaxWidthStrategy(
dynamic map, {
bool validate = true,
}) {
common.MaxWidthStrategy? result;
if (map is common.MaxWidthStrategy) {
result = map;
} else if (map != null) {
assert(SchemaValidator.validate(
schemaId: '$_baseSchemaUrl/max_width_strategy',
value: map,
validate: validate,
));
switch (map) {
case 'ellipsize':
result = common.MaxWidthStrategy.ellipsize;
break;
case 'truncate':
result = common.MaxWidthStrategy.truncate;
break;
default:
throw Exception(
'[decodeMaxWidthStrategy]: map is not supported: [$map]',
);
}
}
return result;
}