How to display rating in SmoothStarRating from sqlite in flutter

864 Views Asked by At

I have a starsmoothrating bar in flutter. I save the rating in my note table. How can I display the same while updating the note?

 Padding(
                padding: const EdgeInsets.all(10.0),
                child: Row(mainAxisAlignment: MainAxisAlignment.start,
                    children:<Widget>[
                      Text("Priority",style: TextStyle(fontSize: 20.0),),
                      Padding(
                        padding: const EdgeInsets.only(left:20.0),
                        child: Container(
                          child: SmoothStarRating(
                            size: height=50.0,
                            allowHalfRating: false,
                            onRated: (value) {
                              this.note.prty=value;
                            },
                          ),
                        ),
                      )]),
              ),
2

There are 2 best solutions below

2
Fathima Shafana On BEST ANSWER

Yes thanku Krish Bhanushali it worked I just used the rating parameter.

SmoothStarRating(
                            size: height=50.0,
                            allowHalfRating: false,
                            rating: note.prty ?? 0,
                            onRated: (v) {
                              setState(() {
                                this.note.prty=v;

                              });
                              
                            },
                          ),
                           
1
Muhammad Arbaz Zafar On

so use set state like i use in my below example and i give mention example below.

 SmoothStarRating(
                                    allowHalfRating: false,
                                     onRated: (v) {
                                      setState(() {
                                         rating=v;
                                       });
                                       print(rating);
                                    },
                                     starCount: 5,

                                     size: 40.0,
                                     // isReadOnly:true,
                                     filledIconData: Icons.star,
                                     halfFilledIconData: Icons.star_half,
                                     color: MyColors.black,
                                     borderColor: MyColors.grey,
                                     spacing:0.0
                                 ),