getAllColValues static method
Get values from string
Implementation
static Map<String, int> getAllColValues(
String sizes,
) {
final Map<String, int> subResult = {};
final List<String> getPrefixList = sizes
.toLowerCase()
.trim()
.split(' ')
.where((String order) => order.trim().isNotEmpty)
.toList();
for (final String element in getPrefixList) {
final List<String> splittedList = element.split('-');
if (splittedList.length == 2) {
if (splittedList.first == 'col' &&
int.tryParse(splittedList.last) != null) {
if (int.parse(splittedList.last) <= 12) {
subResult['sm'] = int.parse(splittedList.last);
}
}
} else if (splittedList.length == 3) {
if (splittedList.first == 'col' &&
int.tryParse(splittedList.last) != null) {
if (int.parse(splittedList.last) <= 12) {
subResult[splittedList.elementAt(1)] = int.parse(splittedList.last);
}
}
}
}
final Map<String, int> result = {};
for (int i = 0; i < prefixesReversedList.length; i++) {
String prefix = prefixesReversedList.elementAt(i);
int nullValue =
i == 0 ? 12 : result[prefixesReversedList.elementAt(i - 1)]!;
result[prefix] = subResult[prefix] ?? nullValue;
}
return result;
}