MimeType class

Represents MIME-Type. Useful for Content-Type and file handling.

Supported aliases:

  • json: application/javascript
  • javascript, js: application/javascript
  • jpeg: image/jpeg
  • png: image/png
  • text: text/plain
  • html: text/html
  • css: text/css
  • zip: application/zip
  • gzip, gz: application/gzip
  • pdf: application/pdf

Constructors

MimeType(String type, String subType, [String? charSet])

Properties

charset String?
final
charsetEncoding Encoding?
no setter
fileExtension String
Returns the common file extension for the MIME-Type.
no setter
fullType String
Returns $type/$subType.
no setter
hasCharset bool
Returns true if charset is defined.
no setter
hashCode int
The hash code for this object.
no setteroverride
htmlTag String?
Returns the HTML tag name for this MIME-Type.
no setter
isAudio bool
Returns true if this a audio MIME-Type.
no setter
isCharsetLATIN1 bool
Returns true if charset is LATIN-1.
no setter
isCharsetUTF8 bool
Returns true if charset is UTF-8.
no setter
isCharsetUTF16 bool
Returns true if charset is UTF-16.
no setter
isFormURLEncoded bool
Returns true if is application/x-www-form-urlencoded.
no setter
isImage bool
Returns true if this a image MIME-Type.
no setter
isImageJPEG bool
Returns true if this is image/jpeg.
no setter
isImagePNG bool
Returns true if this is image/png.
no setter
isImageSVG bool
Returns true if this is image/svg+xml.
no setter
isImageWebP bool
Returns true if this is image/png.
no setter
isJavascript bool
no setter
isJSON bool
Returns true if is application/json.
no setter
isStringType bool
Returns true if type is better represented as String.
no setter
isText bool
Returns true if is text/*.
no setter
isVideo bool
Returns true if this a video MIME-Type.
no setter
isXHTML bool
Returns true if is XHTML.
no setter
isXML bool
Returns true if is XML.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
subType String
final
type String
final

Methods

fileName([String? identifier, String delimiter = '-']) String
Generates a file name for the type, using identifier as name and the corresponding fileExtension.
fileNameRandom() String
Generates a random file name for the type, with the corresponding fileExtension.
fileNameTimeMillis([int? timeMillis]) String
Generates a file name for the type, using timeMillis as name and the corresponding fileExtension.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString([bool? withCharset]) String
A string representation of this object.
override

Operators

operator ==(Object other) bool
The equality operator.
override

Static Methods

asString(Object? mimeType, [String? defaultMimeType]) String?
Parses a mimeType to a MIME-Type string.
byExtension(String? extension, {bool defaultAsApplication = true}) MimeType?
Creates an instance by file extension.
normalizeCharset(String? charset) String?
parse(String? mimeType, [String? defaultMimeType]) MimeType?
Constructor that parses a mimeType string.
parseAsString(String? mimeType, [String? defaultMimeType]) String?
Parses a mimeType string and returns as a normalized MIME-Type string. Note that this can resolve aliases like JSON.

Constants

applicationDart → const String
applicationGzip → const String
applicationJavaScript → const String
applicationJson → const String
applicationPDF → const String
applicationXHTML → const String
applicationXML → const String
applicationYaml → const String
applicationZip → const String
audioMPEG → const String
audioWebm → const String
css → const String
dart → const String
fontOtf → const String
fontTtf → const String
fontWoff → const String
fontWoff2 → const String
gif → const String
gzip → const String
html → const String
icon → const String
imageGIF → const String
imageIcon → const String
imageJPEG → const String
imagePNG → const String
imageSVG → const String
imageWebp → const String
javaScript → const String
jpeg → const String
json → const String
markdown → const String
mp3 → const String
mpeg → const String
otf → const String
pdf → const String
png → const String
svg → const String
text → const String
textCSS → const String
textHTML → const String
textMarkdown → const String
textPlain → const String
ttf → const String
videoMPEG → const String
videoWebm → const String
weba → const String
webm → const String
webp → const String
woff → const String
woff2 → const String
xhtml → const String
xml → const String
yaml → const String
zip → const String