MultiDimensionValue.parse constructor
MultiDimensionValue.parse(
- dynamic value
Parses the given value
to a MultiDimensionValue.
Implementation
factory MultiDimensionValue.parse(dynamic value) {
if (value == null) {
return MultiDimensionValue._([]);
}
if (value is double) {
return MultiDimensionValue._([DimensionValue(value)]);
}
if (value is int) {
return MultiDimensionValue._([DimensionValue(value.toDouble())]);
}
if (value is! String) {
return MultiDimensionValue._([]);
}
// Split on spaces and parse each value to a size
final values = value
.split(' ')
.map(DimensionValue.maybeParse)
.where((element) => element != null)
.cast<DimensionValue>()
.toList();
return MultiDimensionValue._(values);
}