ofFile static method
Returns mime type of file
based on its extension
Implementation
static String? ofFile(File file, {Iterable<MimeTypeDetector>? detectors}) {
if (detectors != null) {
final mimeType = detectors
.map((e) => e(file))
.firstWhere((mime) => mime != null, orElse: () => null);
if (mimeType != null) {
return mimeType;
}
}
String fileExtension = p.extension(file.path);
if (fileExtension.startsWith('.'))
fileExtension = fileExtension.substring(1);
if (fileExtension.length == 0) {
return null;
}
if (fromFileExtension.containsKey(fileExtension)) {
return fromFileExtension[fileExtension];
}
return null;
}