decodeSelectionMode static method
Expects the map
to be either a common.SelectionMode
or a String
containing one of the following values:
expandToDomain
selectOverlapping
single
Implementation
static common.SelectionMode? decodeSelectionMode(
dynamic map, {
bool validate = true,
}) {
common.SelectionMode? result;
if (map is common.SelectionMode) {
result = map;
} else if (map != null) {
assert(SchemaValidator.validate(
schemaId: '$_baseSchemaUrl/selection_mode',
value: map,
validate: validate,
));
switch (map) {
case 'expandToDomain':
result = common.SelectionMode.expandToDomain;
break;
case 'selectOverlapping':
result = common.SelectionMode.selectOverlapping;
break;
case 'single':
result = common.SelectionMode.single;
break;
default:
throw Exception('Unknown [SelectionMode] encountered: [$map]');
}
}
return result;
}