I am using the like_button package from this repository (https://pub.dev/packages/like_button) in my Flutter application. The like button animation was working fine under normal conditions. However, after I added a method to be executed when the button is pressed, the animation stopped working as expected.
I can confirm that the method is working properly, but the frontend animation of the like button is not working. It seems to be related to this method, as the animation works fine without it.
Here is the relevant code:
Future<bool> onLikeButtonTapped(bool isLiked) async {
print('pressed');
await toggleFavorite();
print(success);
return !isLiked;
/// if failed, you can do nothing
// return success? !isLiked:isLiked;
}
}
Future<void> toggleFavorite() async {
if (favorites.contains(current)) {
favorites.remove(current);
} else {
favorites.add(current);
}
print(favorites);
notifyListeners();
}
The toggleFavorite() function, which is an asynchronous function that performs some operation. After adding this method, the like button animation stopped working. But the function is working properly and I can see the output.