From 7b423f40d61052132af6bac2d5d34c4a769d1631 Mon Sep 17 00:00:00 2001 From: Sahil Kumar Date: Fri, 19 Sep 2025 13:43:18 +0200 Subject: [PATCH 1/2] fix(ui): correctly save videos to gallery on mobile This commit fixes an issue where videos downloaded from attachments were not correctly saved to the device's gallery on mobile platforms. The `saveFile` method in `StreamAttachmentHandler` now uses `Gal.putVideo` for video files and `Gal.putImage` for image files. If the file type is neither image nor video, it's saved to the app's directory without being copied to the gallery. Additionally, the temporary file is now only deleted if it was successfully copied to the gallery. --- .../handler/stream_attachment_handler_io.dart | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) 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; } From 9c6f7411e56826efdb6a1ea9f8690878bb9c1124 Mon Sep 17 00:00:00 2001 From: Sahil Kumar Date: Fri, 19 Sep 2025 13:45:00 +0200 Subject: [PATCH 2/2] chore: update CHANGELOG.md --- packages/stream_chat_flutter/CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/stream_chat_flutter/CHANGELOG.md b/packages/stream_chat_flutter/CHANGELOG.md index 5d76e9793..1a8078077 100644 --- a/packages/stream_chat_flutter/CHANGELOG.md +++ b/packages/stream_chat_flutter/CHANGELOG.md @@ -3,6 +3,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) ## 9.16.0