Using Google places and RatingBarIndicator. Everything is working as it should however, in addition to the rating stars I would love to have the rating number to the right of the stars, however, all documentation I have seen on RatingBarIndicator doesn't show how to get the number from the API.
places.dart
class Place {
final String name;
final double rating;
final int userRatingCount;
final String vicinity;
final Geometry geometry;
Place(
{this.name,
this.rating,
this.userRatingCount,
this.vicinity,
this.geometry});
Place.fromJson(Map<dynamic,dynamic> parsedJson)
:name = parsedJson['name'],
rating = (parsedJson['rating'] !=null) ? parsedJson['rating'].toDouble() : null,
userRatingCount = (parsedJson['user_rating_total'] != null) ? parsedJson['user_rating_total'] : null,
vicinity = parsedJson['vicinity'],
geometry = Geometry.fromJson(parsedJson['geometry']);
}
Map.dart
Expanded(
child: ListView.builder(
itemCount: places.length,
itemBuilder: (context, index) {
return FutureProvider(
create: (context) =>
geoService.getDistance(
currentPosition.latitude,
currentPosition.longitude,
places[index].geometry.location.lat,
places[index].geometry.location.lat,
),
child: Card(
child: ListTile(
title: Text(places[index].name),
subtitle: Column(children: <Widget>[
(places[index].rating != null) ? Row(children: <Widget>[
RatingBarIndicator(
rating: places[index].rating,
itemBuilder: (context, index) => Icon(Icons.star, color: Colors.amber),
itemCount: 5,
itemSize: 10,
direction: Axis.horizontal,
),
],) : Row(),
Consumer<double>(
builder: (context, meters, widget){
}
),
],),
),
),
);
}),
)