buildStar method

Widget buildStar(
  1. BuildContext context,
  2. int index
)

Implementation

Widget buildStar(BuildContext context, int index) {
  IconData iconData;
  if (index >= rating) {
    iconData = emptyIcon ?? Icons.star_border;
  } else if (index > rating - 1 && index < rating) {
    iconData = halfFilledIcon ?? Icons.star_half;
  } else {
    iconData = filledIcon ?? Icons.star;
  }

  Icon icon = Icon(
    iconData,
    color:
        index >= rating ? borderColor ?? Colors.grey : color ?? Colors.yellow,
    size: size,
  );

  return InkResponse(
    highlightColor: Colors.transparent,
    radius: size ?? MediaQuery.of(context).size.width / starCount / 2,
    onTap:
        onRatingChanged == null ? null : () => onRatingChanged!(index + 1.0),
    onLongPress: allowHalfRating && onRatingChanged != null
        ? () => onRatingChanged!(index + 0.5)
        : null,
    child: icon,
  );
}