Closed Infinitism closed 2 years ago
I found the solution to this.
Instead of checking the database on the current like state of an item and setting it on "isLiked" parameter, use the likeBuilder to render the appropriate "isLiked" widget based on the database value.
This will make sure that when the item is un-liked, the value is set to false in database, and when like again, the animation will happen as well!
And I think onTap
should return not return isLiked
, this should be !isLiked
.
Hi,
Whenever I set the "isLiked" value on the widget, the animation stops working.
Scenario: I query the database to see what the current "like" state is and set it on the like_button. When user "un-hearts" it, db updates the like state which is reflected in the value I set for "isLiked" parameter for the widget.
Whenever "isLiked" is set to a value other than "false", the "un like" to "like" animation stops working.
` Expanded( child: LikeButton( isLiked: currentLikeState, mainAxisAlignment: MainAxisAlignment.end, size: 30, likeBuilder: (isLiked) { return isLiked ? Icon( Icons.favorite, color: Colors.pink, ) : Icon( Icons.favorite_outline, color: Colors.grey, ); }, onTap: (prevLikeState) async {
), )
`