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