getPercentRating method Null safety

double getPercentRating()

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

Implementation

double getPercentRating() {
  if (_type != RatingStyle.percentage) return -1;
  final localValue = _value as double?;
  if (localValue == null || localValue < 0 || localValue > 100) return -1;
  return localValue;
}