You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a listview and for each row, I added the option to add it as a favorite. I also have a condition in the backend that if the number of favorites is more than 10, the responsecode equals to 2 and shows an error in the flutter and does not add it to the favorite.
Everything works perfectly. The only problem that I have is that in conditions with more than 10 favorites, however, it does not add it to the list (when I refresh the page, it hsows as unmarked), but when I click, it marks as favorite. How could I unmark it as favorite, for example, when user closes the showDialog?
Any other approach is also appreciated like simulating the onpressed action to undo the action of favoriting.
Thank you in advance.
StarButton(
isStarred: UserFavorite
.Users!
valueChanged: (_isStarred) {
if (_isStarred == true)
setState(() async {
var resp =
await add(
widget.oauth,
widget.gatewayId,);
if (resp.responseCode ==
2) {
await showDialog(
context: context,
builder:
(alertDialogContext) {
return AlertDialog(
title: Text(
'Limit Reached'),
content: Text(
'You are allowed to add up to 10 sensors as your favorite.'),
actions: [
TextButton(
child: Text(
'Ok'),
onPressed:
() {
Navigator.pop(
alertDialogContext);
},
),
],
);
},
);
}
});
else
setState(() {
delete(
widget.oauth,
widget.Id,
);
});
},
)
The text was updated successfully, but these errors were encountered:
I suspect the issue is here isStarred: UserFavorite.Users!
Are you sure the value is right, it should be false when you refresh the page.
Thanks for the reply.
this part has no issue. I am using a listview and for each row, I check if it is already false or true and it shows as it is.
The code works perfectly but my problem is that I want to have a limit on the number of favorited rows. Even the condition works perfectly(does not allow more than 10 favorite) but when users click on the favorite button, it first makes it as favorite(color is changed and it is my problem) and then gives the warning. However, when I refresh the page, it is not favorited.
Do you have any suggestion that it does not show as the favorite and revert to not favorite after user read the alertdialog?
I have a listview and for each row, I added the option to add it as a favorite. I also have a condition in the backend that if the number of favorites is more than 10, the responsecode equals to 2 and shows an error in the flutter and does not add it to the favorite.
Everything works perfectly. The only problem that I have is that in conditions with more than 10 favorites, however, it does not add it to the list (when I refresh the page, it hsows as unmarked), but when I click, it marks as favorite. How could I unmark it as favorite, for example, when user closes the showDialog?
Any other approach is also appreciated like simulating the onpressed action to undo the action of favoriting.
Thank you in advance.
The text was updated successfully, but these errors were encountered: