openLocationPicker function
Future<SunnyPlace?>
openLocationPicker(
- BuildContext context, {
- SunnyPlace? toUpdate,
- Set<
String> ? locationTypes,
Implementation
Future<SunnyPlace?> openLocationPicker(BuildContext context,
{SunnyPlace? toUpdate, Set<String>? locationTypes}) async {
try {
final place =
await openAddressPicker(context, locationTypes: locationTypes);
if (place == null) return null;
final SunnyPlace location = toUpdate ?? IPhysicalLocation.of();
final placesApi = gmaps.GoogleMapsPlaces(
apiKey: ThirdPartyCreds.googlePlaces.credentials);
final response = await placesApi.getDetailsByPlaceId(place.placeId!);
final details = response.result;
location.fromGooglePlaceDetails(details, placeId: place.placeId);
location.prune(PhysicalLocationFields.values);
return location;
} catch (e, stack) {
print(e);
_log.severe(e, null, stack);
return null;
}
}