decodeVisualDensity static method
Decodes the value
to a VisualDensity. Supported values are:
adaptivePlatformDensity
comfortable
compact
standard
Implementation
static VisualDensity? decodeVisualDensity(
dynamic value, {
bool validate = true,
}) {
VisualDensity? result;
if (value is VisualDensity) {
result = value;
} else {
_checkSupported(
'VisualDensity',
[
'adaptivePlatformDensity',
'comfortable',
'compact',
'standard',
],
value,
);
if (value != null) {
assert(SchemaValidator.validate(
schemaId: '$_baseSchemaUrl/visual_density',
value: value,
validate: validate,
));
switch (value) {
case 'adaptivePlatformDensity':
result = VisualDensity.adaptivePlatformDensity;
break;
case 'comfortable':
result = VisualDensity.comfortable;
break;
case 'compact':
result = VisualDensity.compact;
break;
case 'standard':
result = VisualDensity.standard;
break;
}
}
}
return result;
}