I got a list of PostItem with a FutureBuilder.
PostItem got a like button and a like count.
When a click on the post, I go into its details. And I can like the post on this screen.
Here is when I click on the like button in detail screen :
Future<void> _updateLike() async
{
PhpPost phpPost = PhpPost();
phpPost.posteModel = widget.postModel;
if(_isLike)
{
String res = await phpPost.unlikePost();
if(res=="OK")
{
setState(() {
_isLike = false;
});
}
}
else
{
String res = await phpPost.likePost();
if(res=="OK")
{
setState(() {
_isLike = true;
});
}
}
widget.postModel.isLike = _isLike;
}
The screen detail update nicely but when I go back at the home screen the post item not updated the like.
Here is how I go to detail from post item :
Navigator.pushNamed(context, '/post_detail', arguments: widget.postModel);

