From 967354c5215ee9b2214216ff10284f592e2c076c Mon Sep 17 00:00:00 2001 From: Rene Floor Date: Thu, 19 Mar 2026 16:18:55 +0100 Subject: [PATCH 1/2] fix duration on video attachments --- melos.yaml | 2 +- .../options/stream_gallery_picker.dart | 4 +++ .../stream_message_input_attachment_list.dart | 5 +++- .../stream_photo_gallery_tile.dart | 30 ++++--------------- packages/stream_chat_flutter/pubspec.yaml | 2 +- 5 files changed, 16 insertions(+), 27 deletions(-) diff --git a/melos.yaml b/melos.yaml index 7dc48f120..0e0e892cd 100644 --- a/melos.yaml +++ b/melos.yaml @@ -95,7 +95,7 @@ command: stream_core_flutter: git: url: https://github.com/GetStream/stream-core-flutter.git - ref: 8057a775c2ed764dbd5cbabd2dd60d3cd68d2f08 + ref: 28f914ddf41700c0ef14b132f6c284b986658db4 path: packages/stream_core_flutter synchronized: ^3.1.0+1 thumblr: ^0.0.4 diff --git a/packages/stream_chat_flutter/lib/src/message_input/attachment_picker/options/stream_gallery_picker.dart b/packages/stream_chat_flutter/lib/src/message_input/attachment_picker/options/stream_gallery_picker.dart index b5a4e3cd4..6c65b74e8 100644 --- a/packages/stream_chat_flutter/lib/src/message_input/attachment_picker/options/stream_gallery_picker.dart +++ b/packages/stream_chat_flutter/lib/src/message_input/attachment_picker/options/stream_gallery_picker.dart @@ -271,6 +271,10 @@ extension StreamImagePickerX on StreamAttachmentPickerController { extraDataMap['file_size'] = file.size!; + if (type == AssetType.video) { + extraDataMap['duration'] = asset.videoDuration.inSeconds; + } + final attachment = Attachment( id: asset.id, file: file, diff --git a/packages/stream_chat_flutter/lib/src/message_input/stream_message_input_attachment_list.dart b/packages/stream_chat_flutter/lib/src/message_input/stream_message_input_attachment_list.dart index 2798a1289..f974be9ca 100644 --- a/packages/stream_chat_flutter/lib/src/message_input/stream_message_input_attachment_list.dart +++ b/packages/stream_chat_flutter/lib/src/message_input/stream_message_input_attachment_list.dart @@ -442,8 +442,11 @@ class StreamMediaAttachmentBuilder extends StatelessWidget { @override Widget build(BuildContext context) { + final durationSecs = attachment.extraData['duration'] as num?; + final videoDuration = durationSecs != null ? Duration(seconds: durationSecs.round()) : null; + final mediaBadge = attachment.type == AttachmentType.video - ? const StreamMediaBadge(type: MediaBadgeType.video) + ? StreamMediaBadge(type: MediaBadgeType.video, duration: videoDuration) : null; return Container( diff --git a/packages/stream_chat_flutter/lib/src/scroll_view/photo_gallery/stream_photo_gallery_tile.dart b/packages/stream_chat_flutter/lib/src/scroll_view/photo_gallery/stream_photo_gallery_tile.dart index a9edd1a23..53178a620 100644 --- a/packages/stream_chat_flutter/lib/src/scroll_view/photo_gallery/stream_photo_gallery_tile.dart +++ b/packages/stream_chat_flutter/lib/src/scroll_view/photo_gallery/stream_photo_gallery_tile.dart @@ -116,23 +116,16 @@ class StreamPhotoGalleryTile extends StatelessWidget { child: _GallerySelectedIndicator(selected: selected), ), ), - if (media.type == AssetType.video) ...[ + if (media.type == AssetType.video) Positioned( left: 8, - bottom: 10, - child: Icon(context.streamIcons.videoSolid), - ), - Positioned( - right: 4, - bottom: 10, - child: Text( - media.videoDuration.format(), - style: TextStyle( - color: chatThemeData.colorTheme.barsBg, - ), + bottom: 8, + child: StreamMediaBadge( + type: MediaBadgeType.video, + duration: media.videoDuration, + durationFormat: MediaBadgeDurationFormat.exact, ), ), - ], // https://stackoverflow.com/a/59317162/10036882 Positioned.fill( child: Material( @@ -176,17 +169,6 @@ class _GallerySelectedIndicator extends StatelessWidget { } } -extension on Duration { - String format() { - final s = '$this'.split('.')[0].padLeft(8, '0'); - if (s.startsWith('00:')) { - return s.replaceFirst('00:', ''); - } - - return s; - } -} - /// {@template mediaThumbnailProvider} /// Builds a thumbnail using [ImageProvider]. /// {@endtemplate} diff --git a/packages/stream_chat_flutter/pubspec.yaml b/packages/stream_chat_flutter/pubspec.yaml index 779f8109e..8031d62c7 100644 --- a/packages/stream_chat_flutter/pubspec.yaml +++ b/packages/stream_chat_flutter/pubspec.yaml @@ -62,7 +62,7 @@ dependencies: stream_core_flutter: git: url: https://github.com/GetStream/stream-core-flutter.git - ref: 8057a775c2ed764dbd5cbabd2dd60d3cd68d2f08 + ref: 28f914ddf41700c0ef14b132f6c284b986658db4 path: packages/stream_core_flutter svg_icon_widget: ^0.0.1 synchronized: ^3.1.0+1 From 5f6082b29e3b9455f4b7aa49824b4902de0f5055 Mon Sep 17 00:00:00 2001 From: Rene Floor Date: Fri, 20 Mar 2026 09:33:39 +0100 Subject: [PATCH 2/2] update core reference --- melos.yaml | 2 +- packages/stream_chat_flutter/pubspec.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/melos.yaml b/melos.yaml index 0e0e892cd..f8ca447b1 100644 --- a/melos.yaml +++ b/melos.yaml @@ -95,7 +95,7 @@ command: stream_core_flutter: git: url: https://github.com/GetStream/stream-core-flutter.git - ref: 28f914ddf41700c0ef14b132f6c284b986658db4 + ref: 492f6f4ef8c73c64b3f399f92c5e508b7fb39e55 path: packages/stream_core_flutter synchronized: ^3.1.0+1 thumblr: ^0.0.4 diff --git a/packages/stream_chat_flutter/pubspec.yaml b/packages/stream_chat_flutter/pubspec.yaml index 8031d62c7..106ba49cd 100644 --- a/packages/stream_chat_flutter/pubspec.yaml +++ b/packages/stream_chat_flutter/pubspec.yaml @@ -62,7 +62,7 @@ dependencies: stream_core_flutter: git: url: https://github.com/GetStream/stream-core-flutter.git - ref: 28f914ddf41700c0ef14b132f6c284b986658db4 + ref: 492f6f4ef8c73c64b3f399f92c5e508b7fb39e55 path: packages/stream_core_flutter svg_icon_widget: ^0.0.1 synchronized: ^3.1.0+1