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';
|
||||
|
||||
/// 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user