visualDensity static method
Returns a VisualDensity from the specified string or map.
If the specified value is a string, then it is interpreted as follows:
adaptivePlatformDensity
: returns VisualDensity.adaptivePlatformDensity (which varies by platform).comfortable
: returns VisualDensity.comfortable.compact
: returns VisualDensity.compact.standard
: returns VisualDensity.standard.
Otherwise, if the specified value is a map, then the keys horizontal
and
vertical
(doubles) are used to create a custom VisualDensity. The
specified values must be in the range given by
VisualDensity.minimumDensity to VisualDensity.maximumDensity. Missing
values are interpreted as zero.
Implementation
static VisualDensity? visualDensity(DataSource source, List<Object> key) {
final String? type = source.v<String>(key);
switch (type) {
case 'adaptivePlatformDensity':
return VisualDensity.adaptivePlatformDensity;
case 'comfortable':
return VisualDensity.comfortable;
case 'compact':
return VisualDensity.compact;
case 'standard':
return VisualDensity.standard;
default:
if (!source.isMap(key)) {
return null;
}
return VisualDensity(
horizontal: source.v<double>([...key, 'horizontal']) ?? 0.0,
vertical: source.v<double>([...key, 'vertical']) ?? 0.0,
);
}
}