getStarRating method Null safety

int getStarRating()

Returns a rating value greater or equal to 0.0, or a negative value if the rating style is not star-based, or if it is unrated.

Implementation

int getStarRating() {
  if (_type != RatingStyle.range3stars &&
      _type != RatingStyle.range4stars &&
      _type != RatingStyle.range5stars) {
    return -1;
  }
  return _value as int? ?? -1;
}