in lib/message_format.dart [602:638]
Map<String, Object> _parseSelectBlock(String pattern) {
var argumentName = '';
var replaceRegex = _selectBlockRe;
pattern = pattern.replaceFirstMapped(replaceRegex, (match) {
// string, name
argumentName = match.group(1)!;
return '';
});
var result = <String, Object>{'argumentName': argumentName};
var parts = _extractParts(pattern);
// Looking for (key block)+ sequence. One of the keys has to be "other".
var pos = 0;
while (pos < parts.length) {
var thePart = parts.elementAt(pos);
_checkAndThrow(thePart._value is String, 'Missing select key element.');
var key = thePart._value;
pos++;
_checkAndThrow(
pos < parts.length, 'Missing or invalid select value element.');
thePart = parts.elementAt(pos);
Queue<_BlockTypeAndVal>? value;
if (_ElementType.block == thePart._type) {
value = _parseBlock(thePart._value);
} else {
_checkAndThrow(false, 'Expected block type.');
}
result[key.replaceAll(RegExp('\\s'), '')] = value!;
pos++;
}
_checkAndThrow(
result.containsKey(_other), 'Missing other key in select statement.');
return result;
}