2

I am retrieve value latitude and longitude from JSON in flutter.I try many thing but not git value of lat and long this is my json file

{ "results": [ { "geometry": { "location": { "lat": 19.2058593, "lng": 72.86612 } } } ] }

I try

>  var myMap = json.decode(data.toString());
>       var myName = myMap['results']['geometry']['location']['lat']

but not getting location values.please help me in flutter

androidleraner
  • 107
  • 1
  • 7

1 Answers1

3

Change it to :

 myName = myMap['results'][0]['geometry']['location']['lat']

This is because "geometry" is inside a list. It's at index[0] of this list, after accessing "results".

Huthaifa Muayyad
  • 11,321
  • 3
  • 17
  • 49