Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The value that I put in initialrating doesn't change when rebuilding. #97

Open
NathanDeTroyer opened this issue Dec 25, 2022 · 0 comments

Comments

@NathanDeTroyer
Copy link

RatingBar widget I use:
RatingBar(
initialRating:
user.recommendations[indexOfCurrentSong].rating.toDouble(),
minRating: 1,
direction: Axis.horizontal,
allowHalfRating: false,
itemCount: 5,
itemPadding: EdgeInsets.symmetric(horizontal: 1),
ratingWidget: RatingWidget(
empty: Icon(
Icons.star,
color: Colors.grey,
),
half: Icon(
Icons.star_half,
color: Theme.of(context).colorScheme.primary,
),
full: Icon(
Icons.star,
color: Theme.of(context).colorScheme.primary,
)),
onRatingUpdate: (rating) {
//TO DO: add a rating update to the server!!!!
user.recommendations[indexOfCurrentSong].rating =
rating.toInt();

              user.setSongRating(indexOfCurrentSong, rating.toInt());
              print(rating);
            },
          )

When rebuilding the page with the setState() method, the rating stays the old rating and not the 'new' initialrating.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant