diff --git a/packages/stream_chat_flutter/lib/src/message_list_view.dart b/packages/stream_chat_flutter/lib/src/message_list_view.dart index d4885c86e..aae9d1939 100644 --- a/packages/stream_chat_flutter/lib/src/message_list_view.dart +++ b/packages/stream_chat_flutter/lib/src/message_list_view.dart @@ -162,6 +162,7 @@ class MessageListView extends StatefulWidget { this.textBuilder, this.usernameBuilder, this.showFloatingDateDivider = true, + this.threadSeparatorBuilder, }) : super(key: key); /// Function used to build a custom message widget @@ -277,6 +278,9 @@ class MessageListView extends StatefulWidget { /// A List of user types that have permission to pin messages final List pinPermissions; + /// Builder used to build the thread separator in case it's a thread view + final WidgetBuilder? threadSeparatorBuilder; + @override _MessageListViewState createState() => _MessageListViewState(); } @@ -450,22 +454,7 @@ class _MessageListViewState extends State { if (i == messages.length) return const Offstage(); if (i == 0) return const SizedBox(height: 30); if (i == messages.length + 1) { - final replyCount = widget.parentMessage!.replyCount; - return Container( - decoration: BoxDecoration( - gradient: _streamTheme.colorTheme.bgGradient, - ), - child: Padding( - padding: const EdgeInsets.all(8), - child: Text( - // ignore: lines_longer_than_80_chars - '$replyCount ${replyCount == 1 ? 'Reply' : 'Replies'}', - textAlign: TextAlign.center, - style: _streamTheme - .channelTheme.channelHeaderTheme.subtitle, - ), - ), - ); + return _buildThreadSeparator(); } final message = messages[i]; @@ -576,6 +565,28 @@ class _MessageListViewState extends State { ); } + Widget _buildThreadSeparator() { + if (widget.threadSeparatorBuilder != null) { + return widget.threadSeparatorBuilder!.call(context); + } + + final replyCount = widget.parentMessage!.replyCount; + return DecoratedBox( + decoration: BoxDecoration( + gradient: _streamTheme.colorTheme.bgGradient, + ), + child: Padding( + padding: const EdgeInsets.all(8), + child: Text( + // ignore: lines_longer_than_80_chars + '$replyCount ${replyCount == 1 ? 'Reply' : 'Replies'}', + textAlign: TextAlign.center, + style: _streamTheme.channelTheme.channelHeaderTheme.subtitle, + ), + ), + ); + } + Positioned _buildFloatingDateDivider() => Positioned( top: 20, child: BetterStreamBuilder>(