Use nearby Google places for reviews
All checks were successful
Build and deploy Flutter Web / build (push) Successful in 1m48s
All checks were successful
Build and deploy Flutter Web / build (push) Successful in 1m48s
This commit is contained in:
@@ -20,6 +20,7 @@ class PlaceState {
|
||||
});
|
||||
|
||||
static final _distance = Distance();
|
||||
static const nearbyRecommendationRadiusMeters = 500.0;
|
||||
|
||||
final PlaceTrait selectedTrait;
|
||||
final List<PlaceRecommendation> places;
|
||||
@@ -30,7 +31,17 @@ class PlaceState {
|
||||
final VoiceReviewDraft reviewDraft;
|
||||
|
||||
List<PlaceRecommendation> get recommendations {
|
||||
final ranked = [...places]
|
||||
final coordinate = userCoordinate;
|
||||
if (coordinate == null) {
|
||||
return const [];
|
||||
}
|
||||
|
||||
final nearbyPlaces = places.where((place) {
|
||||
return _distance(coordinate, place.coordinate) <=
|
||||
nearbyRecommendationRadiusMeters;
|
||||
});
|
||||
|
||||
final ranked = [...nearbyPlaces]
|
||||
..sort((a, b) {
|
||||
final aScore = a.traits.contains(selectedTrait) ? 1 : 0;
|
||||
final bScore = b.traits.contains(selectedTrait) ? 1 : 0;
|
||||
@@ -39,11 +50,6 @@ class PlaceState {
|
||||
return scoreOrder;
|
||||
}
|
||||
|
||||
final coordinate = userCoordinate;
|
||||
if (coordinate == null) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return _distance(
|
||||
coordinate,
|
||||
a.coordinate,
|
||||
|
||||
Reference in New Issue
Block a user