update extensions
This commit is contained in:
@@ -2,14 +2,17 @@ import 'package:http_parser/http_parser.dart' as http_parser;
|
|||||||
import 'package:mime/mime.dart';
|
import 'package:mime/mime.dart';
|
||||||
|
|
||||||
/// Useful extension functions for [String]
|
/// Useful extension functions for [String]
|
||||||
extension StringX on String? {
|
extension StringX on String {
|
||||||
/// Returns the mime type from the passed file name.
|
/// Returns the mime type from the passed file name.
|
||||||
http_parser.MediaType? get mimeType {
|
http_parser.MediaType? get mimeType {
|
||||||
if (this == null) return null;
|
if (toLowerCase().endsWith('heic')) {
|
||||||
if (this!.toLowerCase().endsWith('heic')) {
|
|
||||||
return http_parser.MediaType.parse('image/heic');
|
return http_parser.MediaType.parse('image/heic');
|
||||||
} else {
|
} else {
|
||||||
return http_parser.MediaType.parse(lookupMimeType(this!)!);
|
final mimeType = lookupMimeType(this);
|
||||||
|
if (mimeType == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return http_parser.MediaType.parse(mimeType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user