buildStar method

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

Implementation

Widget buildStar(BuildContext context, int index) {
  Icon icon;
  double ratingStarSizeRelativeToScreen =
      MediaQuery.of(context).size.width / starCount;

  if (index >= rating) {
    icon = new Icon(
      Icons.star_border,
      color: borderColor ?? Theme.of(context).buttonColor,
      size: size ?? ratingStarSizeRelativeToScreen,
    );
  } else if (index > rating - 1 && index < rating) {
    icon = new Icon(
      Icons.star_half,
      color: color ?? Theme.of(context).primaryColor,
      size: size ?? ratingStarSizeRelativeToScreen,
    );
  } else {
    icon = new Icon(
      Icons.star,
      color: color ?? Theme.of(context).primaryColor,
      size: size ?? ratingStarSizeRelativeToScreen,
    );
  }
  return new InkResponse(
    highlightColor: Colors.transparent,
    radius: (size ?? ratingStarSizeRelativeToScreen)/2,
    onTap:
        onRatingChanged == null ? null : () => onRatingChanged(index + 1.0),
    child: new Container(
      height: (size ?? ratingStarSizeRelativeToScreen) * 1.5,
      child: icon,
    ),
  );
}