Closed rlee1990 closed 3 years ago
When I try to remove a reaction that I already selected it just sets it to the first reaction. Checking if isChecked always returns true.
FlutterReactionButtonCheck( onReactionChanged: (reaction, index, isChecked) { print('click: $index'); if (isChecked) { print(isChecked); if (!_likeExists(widget.post!.likeReactions)) { setState(() { selectedReation = reaction; widget.streamClient!.reactions.add('like', widget.post!.id!, userId: widget.streamClient!.currentUser!.userId, data: { 'value': index, }); widget.post!.likesCount = widget.post!.likesCount! + 1; StreamAPI().sendLikeNotificationPost( widget.streamClient!, widget.streamClient!.currentUser!.userId, widget.post!.owner, widget.post!.id, index); }); } else if (_likeExists(widget.post!.likeReactions)) { setState(() { selectedReation = reaction; widget.streamClient!.reactions.update(like.likeId!, data: { 'value': index, }); }); } } else { if (_likeExists(widget.post!.likeReactions)) { setState(() { selectedReation = reaction; widget.streamClient!.reactions.delete(like.likeId!); widget.post!.likesCount = widget.post!.likesCount! - 1; }); } } }, isChecked: selectedReation != null ? true : false, reactions: SNAB().reactions, initialReaction: _likeExists(widget.post!.likeReactions) ? SNAB().reactions[like.value!] : Reaction( id: 7, icon: Image.asset( 'assets/images/100.png', height: 20, color: Colors.grey[600], )), selectedReaction: selectedReation, ),
Sorry was using the isChecked field wrong.
When I try to remove a reaction that I already selected it just sets it to the first reaction. Checking if isChecked always returns true.