lookupAddressInGoogle function

Future<GooglePlaceId?> lookupAddressInGoogle(
  1. SunnyPlace place
)

Implementation

Future<GooglePlaceId?> lookupAddressInGoogle(SunnyPlace place) async {
  final address = addressToString(place)!.join(" ");
  final placesApi =
      gmaps.GoogleMapsPlaces(apiKey: ThirdPartyCreds.googlePlaces.credentials);
  final response = await placesApi.searchByText(address);
  if (response.results.isNotEmpty != true) {
    return null;
  } else {
    for (final result in response.results) {
      return GooglePlaceId(result.placeId);
    }
  }
  return null;
}