首页 > 解决方案 > 如何在 Flutter 中的 sqlite 在 SmoothStarRating 中显示评分

问题描述

我有一个颤动的星星平滑酒吧。我将评级保存在我的笔记表中。更新笔记时如何显示相同的内容?

 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;
                            },
                          ),
                        ),
                      )]),
              ),

标签: flutterratingbar

解决方案


所以像我在下面的例子中使用的那样使用设置状态,我在下面给出例子。

 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
                                 ),

推荐阅读