parse static method

CoapMediaType? parse(
  1. String value, [
  2. String? encoding
])

Parses a string-based contentType value and encoding and returns a CoapMediaType, if a match has been found.

Otherwise, it returns null.

Implementation

static CoapMediaType? parse(final String value, [final String? encoding]) {
  final contentType = ContentType.parse(value);

  return CoapMediaType.values.firstWhereOrNull(
    (final element) =>
        element.contentType.toString() == contentType.toString() &&
        element.encoding == encoding,
  );
}