geocoder: prevent crash on funky coordinates

This commit is contained in:
Thibault Deckers 2019-08-09 08:20:05 +09:00
parent 21f277bc6a
commit 6d8a3afa9d

View file

@ -110,7 +110,10 @@ class CatalogMetadata {
final double latitude, longitude; final double latitude, longitude;
Address address; Address address;
CatalogMetadata({this.contentId, this.dateMillis, this.keywords, this.latitude, this.longitude}); CatalogMetadata({this.contentId, this.dateMillis, this.keywords, double latitude, double longitude})
// Geocoder throws an IllegalArgumentException when a coordinate has a funky values like 1.7056881853375E7
: this.latitude = latitude < -90.0 || latitude > 90.0 ? null : latitude,
this.longitude = longitude < -180.0 || longitude > 180.0 ? null : longitude;
factory CatalogMetadata.fromMap(Map map) { factory CatalogMetadata.fromMap(Map map) {
return CatalogMetadata( return CatalogMetadata(