androidflutterdartgoogle-places-apigeocode

Get an address for place ID in flutter


am new to flutter

Am working on a project that uses places API and Google map. I want the users to be able to get a place address when they input the place id.

I have been able to retrieve the place id using geocode.

Please how to I get the place address using the place id


Solution

  • Use google_maps_webservice package:

    final geocoding = GoogleMapsGeocoding(
          apiKey: '...........');
    
    final response = await geocoding.searchByPlaceId('ChIJd8BlQ2BZwokRAFUEcm_qrcA');
    
    final result =  response.results[0].formattedAddress;
    // Result will be: 277 Bedford Ave, Brooklyn, NY 11211, USA
    

    Remember to enable the service from the Developer Console.