How to make default flutter ratingbar non clickable ?
I have to disable rating option once user give feedback. How do I do it.
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);
});
});
});
})
CodePudding user response:
IgnorePointer(child:RatingWidget)
CodePudding user response:
You can set ignoreGestures
to true
, like this:
RatingBar(
ignoreGestures: true, // <---- add this
itemSize: 35,
initialRating:0,
glowColor: Colors.transparent,
direction: Axis.horizontal,
allowHalfRating: false,
...
)