Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GooglePlaceAutoCompleteTextField: Unhandled Exception with Null check operator #32

Open
harSofja opened this issue Sep 14, 2023 · 1 comment

Comments

@harSofja
Copy link

I'm encountering an issue with the GooglePlaceAutoCompleteTextField widget from the google_places_flutter package. Every time I type a location into the search bar and select a suggestion from the auto-suggested list, I receive an error in my console logs.

Error:
csharp
Copy code
[VERBOSE-2:dart_vm_initializer.cc(41)] Unhandled Exception: Null check operator used on a null value
#0 _GooglePlaceAutoCompleteTextFieldState.getPlaceDetailsFromPlaceId
google_places_flutter.dart:252

Relevant Code:
dart
Copy code
Future<Response?> getPlaceDetailsFromPlaceId(Prediction prediction) async {
var url = "https://maps.googleapis.com/maps/api/place/details/json?placeid=${prediction.placeId}&key=${widget.googleAPIKey}";
Response response = await Dio().get(url);
PlaceDetails placeDetails = PlaceDetails.fromJson(response.data);
prediction.lat = placeDetails.result!.geometry!.location!.lat.toString();
prediction.lng = placeDetails.result!.geometry!.location!.lng.toString();
widget.getPlaceDetailWithLatLng!(prediction);
}

Steps to Reproduce:
1.Type a location into the GooglePlaceAutoCompleteTextField search bar.
2.Select any location from the suggested dropdown.
3.Observe the error in the console logs.

Additional Context:
The error seems to be related to the getPlaceDetailsFromPlaceId method, specifically when trying to access properties of the placeDetails object. I've ensured that the necessary API keys and configurations are correctly set up.
Thank you in advance.

Screenshots:
unhandled exception marked

relevant code

@kyadalu1
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants