flutterdartgeolocationlatitude-longitudegeocoder

PlatformException when calling Geocoder.local.findAddressesFromCoordinates


How can I convert location latitude and longitude to a formated address? I'm trying with geocoder plugin but the line- await Geocoder.local.findAddressesfromCoordinates(coordinates) gives me an error with showing platform exception. I used this plugin more times and it worked nicely, but this time in all my projects it shows same error, please help to solve.

var coordinates = new Coordinates(latitude, longitude);
var addresses = 
await Geocoder.local.findAddressesFromCoordinates(coordinates);
var first = addresses.first;
var myAddress = first.addressLine;

** When I want to convert coordinates find this error :
Unhandled Exception: PlatformException(failed, Failed, null) show error Message**


Solution

  • Use:

    await Geocoder.google(your_API_Key).findAddressesFromCoordinates(coordinates);
    

    Instead of:

    await Geocoder.local.findAddressesFromCoordinates(coordinates);