Closed dalton5 closed 2 years ago
return ! statusLiked;
if I return !statusLiked it will work however if I have an error in my API call I couldn't come back to the iniitial value. Because the return will have already been done. No?
yes,but you can rollback status if failed
How?
Would you have an example?
Thanks,
Hey have the same problem, the issue is that the Animation doesn't work with the onTap. my OnTap Code is this:
onTap: (isliked) async { likeFuntion( ctx: ctx, like: isliked, //listing.isFavorite, listing: listing, ); },
And my Like funtion is:
Future<bool> likeFuntion({
bool like,
BuildContext ctx,
Listing listing,
}) async {
if (!like) {
Provider.of<Listings2>(ctx, listen: false).addFavorite(listing);
if (listing.listingType != 'Web') {
DatabaseMethods().saveNotification(
'favorited',
listing.userId,
houseImage: listing.photos.first,
listingId: listing.id,
);
}
} else {
Provider.of<Listings2>(ctx, listen: false).removeFavorite(listing.id);
}
listing.toggleFavoriteStatus(listing);
return !like;
}
It works on my Backend however the Animation is completely lost, any Ideas?
Sorry, I found how it will work, just added into the onTap of the Like button the return to the function, now the animation works again.
Sorry, I found how it will work, just added into the onTap of the Like button the return to the function, now the animation works again.
Thanks a lot. Animation works now by returning the function.
Hi,
I would like to be able in the tap event to set the liked state and change the state of the button and then call my API.
It's to avoid lag time of API call.
onTap: (statusLiked) async { // set Likebutton liked = statusLiked how to do it? return await callApi!(taped); },
How can I do it?