dev-juju / flutter_google_maps_webservices

Google maps meb services for flutter
BSD 3-Clause "New" or "Revised" License
4 stars 11 forks source link

Typecast Error for getDetailsByPlaceId method #8

Open Panimaster opened 2 months ago

Panimaster commented 2 months ago

We get the following error using the getDetailsByPlaceId method:

⛔ type 'Null' is not a subtype of type 'String' in type cast<…>

Looking into the issue we found out that the issue is that PlaceDetailsFromJson requires placeID to be part of the response JSON which is unfortunately not present:

image
lukehutch commented 2 months ago

In general no field should ever be assumed to be present in a JSON response. To keep required fields non-nullable, while reporting a better error message in these cases, an informative exception should be thrown:

placeId: json['place_id'] as String? ?? throw 'JSON is missing the "place_id" field',