From 311b109994e05ecd550964d3ebd674e6cc5993a6 Mon Sep 17 00:00:00 2001 From: Gordon Hayes Date: Wed, 8 Sep 2021 14:31:36 +0200 Subject: [PATCH] perf: only build reaction indicator when needed --- .../lib/src/message_widget.dart | 26 ++++++++++++------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/packages/stream_chat_flutter/lib/src/message_widget.dart b/packages/stream_chat_flutter/lib/src/message_widget.dart index d165e52c..41ebcab6 100644 --- a/packages/stream_chat_flutter/lib/src/message_widget.dart +++ b/packages/stream_chat_flutter/lib/src/message_widget.dart @@ -595,6 +595,8 @@ class _MessageWidgetState extends State final bottomRowPadding = widget.showUserAvatar != DisplayWidget.gone ? avatarWidth + 8.5 : 0.5; + final showReactions = _shouldShowReactions; + return Material( type: widget.message.pinned && widget.showPinHighlight ? MaterialType.card @@ -658,15 +660,21 @@ class _MessageWidgetState extends State SizedBox(width: avatarWidth + 4), Flexible( child: PortalEntry( - visible: _shouldShowReactions, - portal: Container( - transform: Matrix4.translationValues( - widget.reverse ? 12 : -12, 0, 0), - constraints: const BoxConstraints( - maxWidth: 22 * 6.0, - ), - child: _buildReactionIndicator(context), - ), + visible: showReactions, + portal: showReactions + ? Container( + transform: + Matrix4.translationValues( + widget.reverse ? 12 : -12, + 0, + 0), + constraints: const BoxConstraints( + maxWidth: 22 * 6.0, + ), + child: _buildReactionIndicator( + context), + ) + : null, portalAnchor: Alignment(widget.reverse ? 1 : -1, -1), childAnchor: