getContentType function
Returns ContentType of the specified path, or null
if not found.
For example,
getContentType("home.js");
getContentType("alpha/home.js");
getContentType("js");
getContentType("alpha/home.js?foo");
//returns ContentType.parse("text/javascript; charset=utf-8")
isExtensionwhetherpathis an extension, e.g., "js". If not specified (i.e., null), extension is assumed if it doesn't contain '.' nor '/'.autoUtf8whether to append "; charset=utf-8" when detecting a text mime type.
Implementation
ContentType? getContentType(String? path,
{List<int>? headerBytes, bool? isExtension, bool autoUtf8 = true}) {
final mime = getMimeType(path, headerBytes: headerBytes,
isExtension: isExtension, autoUtf8: autoUtf8);
if (mime != null) return ContentType.parse(mime);
}