fromText static method

MediaType fromText(
  1. String text
)

Creates a media type from the specified text The text must use the top/sub structure, e.g. 'text/plain'

Implementation

static MediaType fromText(String text) {
  text = text.toLowerCase();
  var splitPos = text.indexOf('/');
  if (splitPos != -1) {
    var topText = text.substring(0, splitPos);
    var top = _topLevelByMimeName[topText] ?? MediaToptype.other;
    var sub = _subtypesByMimeType[text] ?? MediaSubtype.other;
    return MediaType(text, top, sub);
  } else {
    var top = _topLevelByMimeName[text] ?? MediaToptype.other;
    return MediaType(text, top, MediaSubtype.other);
  }
}