fromString static method

Descriptor? fromString(
  1. String? value
)

Parses colon-separated list of descriptor fields and returns them as a Descriptor.

  • value colon-separated descriptor fields to initialize Descriptor. Returns a newly created Descriptor. @throws a ConfigException if the descriptor string is of a wrong format.

Implementation

static Descriptor? fromString(String? value) {
  if (value == null || value.isEmpty) return null;

  var tokens = value.split(':');
  if (tokens.length != 5) {
    throw ConfigException(null, 'BAD_DESCRIPTOR',
            'Descriptor ' + value + ' is in wrong format')
        .withDetails('descriptor', value);
  }

  return Descriptor(tokens[0].trim(), tokens[1].trim(), tokens[2].trim(),
      tokens[3].trim(), tokens[4].trim());
}