getAllOffsetsValue static method
Get offsets values from string
Implementation
static Map<String, int> getAllOffsetsValue(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 == 'offset' &&
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 == 'offset' &&
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 ? 0 : result[prefixesReversedList.elementAt(i - 1)]!;
result[prefix] = subResult[prefix] ?? nullValue;
}
return result;
}