Hello!
It works well when Geolocator().placemarkFromAddress()'s parameter address is right.
But, the address is not right(can't find on google map), this function return " PlatformException (PlatformException(ERROR_GEOCODNG_ADDRESSNOTFOUND, Unable to find coordinates matching the supplied address., null)) "
like this picture
So, if address is not right, How can I get null rather than exception of 'PlatformException (PlatformException(ERROR_GEOCODNG_ADDRESSNOTFOUND, Unable to find coordinates matching the supplied address., null))'?
Hi, you solved this ?
@NaufalHafizi you could simply at a try...catch statement:
List<Placemark> placemarks = null;
try {
placemarks = await Geolocator().placemarkFromAddress(query);
} on PlatformException catch (e) {
if (e.errorCode == 'ERROR_GEOCODING_ADDRESSNOTFOUND') {
placemarks = null;
} else {
// Don't handle this case so rethrow the exception...
rethrow;
}
}
Note that as part of geolocator version 6.0.0 we have moved the geocoding features into their own dedicated plugin and remove the placemarkFromAddress
and placemarkFromCoordinates
from the geolocator plugin.
@NaufalHafizi you could simply at a try...catch statement:
List<Placemark> placemarks = null; try { placemarks = await Geolocator().placemarkFromAddress(query); } on PlatformException catch (e) { if (e.errorCode == 'ERROR_GEOCODING_ADDRESSNOTFOUND') { placemarks = null; } else { // Don't handle this case so rethrow the exception... rethrow; } }
Note that as part of geolocator version 6.0.0 we have moved the geocoding features into their own dedicated plugin and remove the
placemarkFromAddress
andplacemarkFromCoordinates
from the geolocator plugin.
thank you
@NaufalHafizi you could simply at a try...catch statement:
List<Placemark> placemarks = null; try { placemarks = await Geolocator().placemarkFromAddress(query); } on PlatformException catch (e) { if (e.errorCode == 'ERROR_GEOCODING_ADDRESSNOTFOUND') { placemarks = null; } else { // Don't handle this case so rethrow the exception... rethrow; } }
Note that as part of geolocator version 6.0.0 we have moved the geocoding features into their own dedicated plugin and remove the
placemarkFromAddress
andplacemarkFromCoordinates
from the geolocator plugin.thank you
if (e.errorCode == 'ERROR_GEOCODING_ADDRESSNOTFOUND')
here 'e.errorcode' is not working for me
it's showing the getter 'errorcode 'isn't define for the type of 'PlatformException'
will you help see to it .