I'm trying to check if the user likes the current post and set an icon. I'm trying to do a simple check but it throws an error.
The method I created
List<String> fav = List<String>();
checkFav(String id) {
bool isFav = fav.contains(id);
if(isFav)
return true;
else
return null;
}
And where I use the method
IconButton(
icon: Icon(favorite.checkFav(widget.blogModel.id)
? Icons.favorite
: Icons.favorite_border,
color: Colors.redAccent),
onPressed: () {
setState(
() {
favorite.checkFav(widget.blogModel.id)
? favorite.deleteItemToFav(widget.blogModel.id)
: favorite.addItemToFav(widget.blogModel.id);
},
);
//favorite.checkItemInFav(widget.blogModel.id, context);
},
),