From dc2ad3392568734bdf972eaecf806a3d8a15e8fd Mon Sep 17 00:00:00 2001 From: Ali Yunes <76793303+alex-ey99@users.noreply.github.com> Date: Sun, 29 Jan 2023 23:43:48 +0200 Subject: [PATCH] Fix _handleIsLikeChanged which stops animations when a remote initial value of isLiked is provided to LikeButton --- lib/src/like_button.dart | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/src/like_button.dart b/lib/src/like_button.dart index 0746595..9b5e3f5 100644 --- a/lib/src/like_button.dart +++ b/lib/src/like_button.dart @@ -447,7 +447,7 @@ class LikeButtonState extends State with TickerProviderStateMixin { return; } - if (isLiked != null && isLiked != _isLiked) { + if (isLiked != null ) { if (_likeCount != null) { _preLikeCount = _likeCount; if (isLiked) { @@ -456,7 +456,10 @@ class LikeButtonState extends State with TickerProviderStateMixin { _likeCount = _likeCount! - 1; } } - _isLiked = isLiked; + setState((){ + _isLiked = isLiked; + }); + if (mounted) { setState(() {