Search code examples
google-maps-api-3flutterdartgoogle-geocoding-api

Response from geocoding API


I'm able to get the fully formatted address from the api,

"1600 Amphitheatre Parkway, Mountain View, CA 94043, USA"

for example.

How do i "breaking to pieces" this formatted address(city, street, country etc)?

code for getting the fully address -

   final formattedAddress =decodedResponse['results'][0]['formatted_address']

Solution

  • According to the result from the api(https://developers.google.com/maps/documentation/geocoding/intro#GeocodingResponses)

    I can write decodedResponse['results'][0]['address_components'][0]['long_name']

    The second [0] indicate the location of the type