diff --git a/packages/stream_chat_flutter/CHANGELOG.md b/packages/stream_chat_flutter/CHANGELOG.md index 703671887..b080b7404 100644 --- a/packages/stream_chat_flutter/CHANGELOG.md +++ b/packages/stream_chat_flutter/CHANGELOG.md @@ -8,6 +8,8 @@ 🐞 Fixed - Fixed `.replaceMentions` not escaping special characters in the username. +- Fixed videos not being saved to gallery correctly on mobile + platforms. [[#2357]](https://github.com/GetStream/stream-chat-flutter/issues/2357) - Fixed unread indicator button using hardcoded white color instead of theme color `colorTheme.barsBg`. [[#2366]](https://github.com/GetStream/stream-chat-flutter/issues/2366) - Fixed `GradientAvatars` for users with same-length IDs would have identical diff --git a/packages/stream_chat_flutter/lib/src/attachment/handler/stream_attachment_handler_io.dart b/packages/stream_chat_flutter/lib/src/attachment/handler/stream_attachment_handler_io.dart index 9d920d547..02d051f72 100644 --- a/packages/stream_chat_flutter/lib/src/attachment/handler/stream_attachment_handler_io.dart +++ b/packages/stream_chat_flutter/lib/src/attachment/handler/stream_attachment_handler_io.dart @@ -198,10 +198,19 @@ class StreamAttachmentHandler extends StreamAttachmentHandlerBase { // Now that the file is saved, we need to copy it to the user's gallery // because the gallery only shows files that are in the gallery folder. - await Gal.putImage(path); + final copyToGallery = switch (file.mimeType) { + final type? when type.startsWith('image/') => Gal.putImage, + final type? when type.startsWith('video/') => Gal.putVideo, + _ => null, + }; - // Once the file is copied to the gallery, we can delete the temporary file. - await file.delete(); + if (copyToGallery != null) { + await copyToGallery.call(path); + + // If the file was successfully copied to the gallery, we can safely + // delete the temporary file. + await file.delete(); + } return path; }