需要获取评分表 Google 地点 API 而不仅仅是星星
Needing to grab the Rating number form Google Places API and not just the stars
使用 Google 个位置和 RatingBarIndicator。然而,一切都按预期工作,除了评级星之外,我希望在星号右侧显示评级编号,但是,我在 RatingBarIndicator 上看到的所有文档都没有显示如何从 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){
}
),
],),
),
),
);
}),
)
RatingBarIndicator
不提供此功能,您可以在指示器右侧添加带有样式的 Text
小部件以模仿该外观。
使用 Google 个位置和 RatingBarIndicator。然而,一切都按预期工作,除了评级星之外,我希望在星号右侧显示评级编号,但是,我在 RatingBarIndicator 上看到的所有文档都没有显示如何从 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){
}
),
],),
),
),
);
}),
)
RatingBarIndicator
不提供此功能,您可以在指示器右侧添加带有样式的 Text
小部件以模仿该外观。