diff --git a/packages/stream_chat/lib/src/extensions/string_extension.dart b/packages/stream_chat/lib/src/extensions/string_extension.dart index e87eea7e..440e2cb6 100644 --- a/packages/stream_chat/lib/src/extensions/string_extension.dart +++ b/packages/stream_chat/lib/src/extensions/string_extension.dart @@ -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); } } }