diff --git a/packages/stream_chat_flutter/CHANGELOG.md b/packages/stream_chat_flutter/CHANGELOG.md index aee2f296..92cc891c 100644 --- a/packages/stream_chat_flutter/CHANGELOG.md +++ b/packages/stream_chat_flutter/CHANGELOG.md @@ -1,12 +1,14 @@ ## Upcomming -🐞 Fixed -- Fix render overflow issue with `MessageSearchListTileTitle`. It now uses `Text.rich` instead of `Row`. Better default behaviour and allows `TextOverflow`. - 🔄 Changed +- Updated `lottie` dependency to `^2.0.0` - Updated `desktop_drop` dependency to `^0.4.0` - + +🐞 Fixed +- [[#1379]](https://github.com/GetStream/stream-chat-flutter/issues/1379) Fixed "Issues with photo attachments on web", where the cached image attachment would not render while uploading. +- Fix render overflow issue with `MessageSearchListTileTitle`. It now uses `Text.rich` instead of `Row`. Better default behaviour and allows `TextOverflow`. + ## 5.1.0 🐞 Fixed diff --git a/packages/stream_chat_flutter/lib/src/attachment/image_attachment.dart b/packages/stream_chat_flutter/lib/src/attachment/image_attachment.dart index 93bf2926..6a6ee780 100644 --- a/packages/stream_chat_flutter/lib/src/attachment/image_attachment.dart +++ b/packages/stream_chat_flutter/lib/src/attachment/image_attachment.dart @@ -56,22 +56,33 @@ class StreamImageAttachment extends StreamAttachmentWidget { Widget build(BuildContext context) { return source.when( local: () { - if (attachment.localUri == null || attachment.file?.bytes == null) { - return AttachmentError(constraints: constraints); - } - return _buildImageAttachment( - context, - Image.memory( - attachment.file!.bytes!, - height: constraints?.maxHeight, - width: constraints?.maxWidth, - fit: BoxFit.cover, - errorBuilder: (context, _, __) => Image.asset( - 'images/placeholder.png', - package: 'stream_chat_flutter', + if (attachment.file?.bytes != null) { + return _buildImageAttachment( + context, + Image.memory( + attachment.file!.bytes!, + height: constraints?.maxHeight, + width: constraints?.maxWidth, + fit: BoxFit.cover, + errorBuilder: _imageErrorBuilder, ), - ), - ); + ); + } else if (attachment.localUri != null) { + return _buildImageAttachment( + context, + Image.asset( + attachment.localUri!.path, + height: constraints?.maxHeight, + width: constraints?.maxWidth, + fit: BoxFit.cover, + errorBuilder: _imageErrorBuilder, + ), + ); + } else { + return AttachmentError( + constraints: constraints, + ); + } }, network: () { var imageUrl = @@ -116,6 +127,12 @@ class StreamImageAttachment extends StreamAttachmentWidget { ); } + Widget _imageErrorBuilder(BuildContext _, Object __, StackTrace? ___) => + Image.asset( + 'images/placeholder.png', + package: 'stream_chat_flutter', + ); + Widget _buildImageAttachment(BuildContext context, Widget imageWidget) { return Container( constraints: constraints, diff --git a/packages/stream_chat_flutter/pubspec.yaml b/packages/stream_chat_flutter/pubspec.yaml index 633478f3..31ab0cb6 100644 --- a/packages/stream_chat_flutter/pubspec.yaml +++ b/packages/stream_chat_flutter/pubspec.yaml @@ -31,7 +31,7 @@ dependencies: image_gallery_saver: ^1.7.0 image_picker: ^0.8.2 jiffy: ^5.0.0 - lottie: ^1.0.1 + lottie: ^2.0.0 meta: ^1.3.0 path_provider: ^2.0.9 photo_manager: ^2.0.1