Skip to content

Commit 5e37239

Browse files
committed
fix:🐛Reaction widget gets cutOff when it width is greater then message width.
1 parent 31eedc2 commit 5e37239

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

lib/src/models/message_reaction_configuration.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import 'package:flutter/material.dart';
2323

2424
class MessageReactionConfiguration {
2525
/// Used for giving size of reaction on message.
26+
/// Will apply only for one-one chat.
2627
final double? reactionSize;
2728

2829
/// Used for giving margin of reaction on message.

lib/src/widgets/reaction_widget.dart

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,10 @@ class _ReactionWidgetState extends State<ReactionWidget> {
6565

6666
@override
6767
Widget build(BuildContext context) {
68-
//// Convert into set to remove reduntant values
68+
//// Convert into set to remove redundant values
6969
final reactionsSet = widget.reaction.reactions.toSet();
70+
final isGroupChat = widget.reaction.reactedUserIds.length > 2;
71+
7072
return Positioned(
7173
bottom: 0,
7274
right: widget.isMessageBySender && needToExtend ? 0 : null,
@@ -103,12 +105,18 @@ class _ReactionWidgetState extends State<ReactionWidget> {
103105
child: Row(
104106
children: [
105107
Text(
106-
reactionsSet.join(' '),
108+
isGroupChat
109+
? reactionsSet.take(3).join(' ')
110+
: reactionsSet.join(' '),
107111
style: TextStyle(
108-
fontSize: messageReactionConfig?.reactionSize ?? 13,
112+
fontSize: isGroupChat
113+
? messageReactionConfig?.reactionSize ?? 13
114+
: 13,
109115
),
110116
),
111117
if ((chatController?.chatUsers.length ?? 0) > 1) ...[
118+
/// when reaction user length is 3 or <3 && they all have
119+
/// reacted with the same reaction this condition will be true
112120
if (!(widget.reaction.reactedUserIds.length > 3) &&
113121
!(reactionsSet.length > 1))
114122
...List.generate(
@@ -124,6 +132,9 @@ class _ReactionWidgetState extends State<ReactionWidget> {
124132
messageReactionConfig?.profileCircleRadius,
125133
),
126134
),
135+
136+
/// ReactionUser length > 3 && all have reacted with the same
137+
/// reaction then this condition will be executed
127138
if (widget.reaction.reactedUserIds.length > 3 &&
128139
!(reactionsSet.length > 1))
129140
Padding(

0 commit comments

Comments
 (0)