Skip to content

Commit be74767

Browse files
committed
List: fix total count + filter out reactions at 0
1 parent 72224b3 commit be74767

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

packages/flyer_chat_reactions/lib/src/widgets/reactions_list.dart

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,17 @@ class _ReactionsListState extends State<ReactionsList> {
105105
t.typography.bodyMedium,
106106
),
107107
);
108+
final validReactions = widget.reactions.where((r) => r.count > 0).toList();
108109

109110
final filteredReactions =
110111
selectedEmoji == null
111-
? widget.reactions
112-
: widget.reactions.where((r) => r.emoji == selectedEmoji).toList();
112+
? validReactions
113+
: validReactions.where((r) => r.emoji == selectedEmoji).toList();
114+
115+
final totalReactionCount = widget.reactions.fold(
116+
0,
117+
(sum, r) => sum + r.count,
118+
);
113119

114120
return Container(
115121
clipBehavior: Clip.hardEdge,
@@ -131,7 +137,7 @@ class _ReactionsListState extends State<ReactionsList> {
131137
children: [
132138
_buildChip(
133139
label: Text(
134-
'${widget.styleConfig.allFilterChipLabel} • ${widget.reactions.length}',
140+
'${widget.styleConfig.allFilterChipLabel} • $totalReactionCount',
135141
),
136142
theme: theme,
137143
selected: selectedEmoji == null,
@@ -142,7 +148,7 @@ class _ReactionsListState extends State<ReactionsList> {
142148
},
143149
),
144150
const SizedBox(width: 8),
145-
...widget.reactions.map(
151+
...validReactions.map(
146152
(reaction) => Padding(
147153
padding: const EdgeInsets.only(right: 8),
148154
child: _buildChip(

0 commit comments

Comments
 (0)