update extensions

This commit is contained in:
Salvatore Giordano
2021-04-19 15:53:12 +02:00
parent 9f01e71ed3
commit 3083839714
@@ -2,14 +2,17 @@ import 'package:http_parser/http_parser.dart' as http_parser;
import 'package:mime/mime.dart';
/// Useful extension functions for [String]
extension StringX on String? {
extension StringX on String {
/// Returns the mime type from the passed file name.
http_parser.MediaType? get mimeType {
if (this == null) return null;
if (this!.toLowerCase().endsWith('heic')) {
if (toLowerCase().endsWith('heic')) {
return http_parser.MediaType.parse('image/heic');
} else {
return http_parser.MediaType.parse(lookupMimeType(this!)!);
final mimeType = lookupMimeType(this);
if (mimeType == null) {
return null;
}
return http_parser.MediaType.parse(mimeType);
}
}
}