fromString static method
Parses a string to get descriptor fields and returns them as a Descriptor.
The string must have format name,library
value
a string to parse. Returns a newly created Descriptor. Throws a ConfigException if the descriptor string is of a wrong format.
See toString
Implementation
static TypeDescriptor? fromString(String? value) {
if (value == null || value.isEmpty) return null;
var tokens = value.split(',');
if (tokens.length == 1) {
return TypeDescriptor(tokens[0].trim(), null);
} else if (tokens.length == 2) {
return TypeDescriptor(tokens[0].trim(), tokens[1].trim());
} else {
throw ConfigException(null, 'BAD_DESCRIPTOR',
'Type descriptor ' + value + ' is in wrong format')
.withDetails('descriptor', value);
}
}