mimeType property

String mimeType

The MIME type of the data URI.

A data URI consists of a "media type" followed by data. The media type starts with a MIME type and can be followed by extra parameters. If the MIME type representation in the URI text contains URI escapes, they are unescaped in the returned string. If the value contain non-ASCII percent escapes, they are decoded as UTF-8.

Example:

data:text/plain;charset=utf-8,Hello%20World!

This data URI has the media type text/plain;charset=utf-8, which is the MIME type text/plain with the parameter charset with value utf-8. See RFC 2045 for more detail.

If the first part of the data URI is empty, it defaults to text/plain.

Implementation

String get mimeType {
  int start = _separatorIndices[0] + 1;
  int end = _separatorIndices[1];
  if (start == end) return "text/plain";
  return _Uri._uriDecode(_text, start, end, utf8, false);
}