如何使评级栏在Flutter中不可点击

64jmpszr  于 2023-01-31  发布在  Flutter
关注(0)|答案(2)|浏览(131)

如何使默认的Flutter评级栏不可点击?
我必须禁用评级选项,一旦用户给予反馈。我怎么做。

RatingBar(
  itemSize: 35,
  initialRating: 0,
  glowColor: Colors.transparent,
  direction: Axis.horizontal,
  allowHalfRating: false,
  tapOnlyMode: false,
  itemCount: 5,
  itemPadding: const EdgeInsets.symmetric(horizontal: 0.0),
  ratingWidget: RatingWidget(
    full: Image.asset(img_star_rating_fill, width: 25.w, height: 25.h),
    // full: const Icon(Icons.star, color:yellow_FFC800),
    half: Image.asset(img_star_rating_fill, width: 25.w, height: 25.h),
    // half: const Icon(Icons.star_half, color:yellow_FFC800,),
    empty:
        Image.asset(img_star_rating_empty, width: 25.w, height: 25.h),
  ),
  // empty: const Icon(Icons.star_outline, color:gray_868590,)),
  onRatingUpdate: (value) {
    setState(() {
      _ratingValue = value;

      printData(
          'Rating to consultation booking ID', _ratingValue.toString());
      controller
          .callRateConsultationAPI(
              widget.i,
              controller.pastBookingList[widget.i].id.toString(),
              value.toString())
          .then((value) {
        setState(() {
          // ratingBar.setFocusable(false);
        });
      });
    });
  })
fdx2calv

fdx2calv1#

可以将ignoreGestures设置为true,如下所示:

RatingBar(
    ignoreGestures: true, // <---- add this
    itemSize: 35,
    initialRating:0,
    glowColor: Colors.transparent,
    direction: Axis.horizontal,
    allowHalfRating: false,
   ...
)
fae0ux8s

fae0ux8s2#

IgnorePointer(child:RatingWidget)

相关问题