0

I have a flutter http get request that returns a response in the below format

{
   
    "area": "some area",
    "user_places": [
        {
            "place_id": "105",
            "place_name": "Place 1"
        },
        {
            "place_id": "104",
            "place_name": "place 2"
        }
    ],
    "lang": null,
    "token": "IiwiZGV2aWNlIjoid2ViIiwiZGllIjoiMjAyMS0wNS0xMiAyMjo0NTozOSJ9.2wJlmHNRmQ0_rfNbca2-DNek1dzT9Em8-iQIfGFZJ98",
    "account_type": 1,
    
}

Am currently able to get data from a field directly below the map for example "area" . My question is how to get data from a list inside the map in this case "user_places". Say I wanted to display all "place_id" and "place_name" in a widget somewhere in my app. How would I go about it?

1 Answer 1

1

you can use a tool like json to dart you can paste your json data and get a dart class of the same

class MyLocation {
  String area;
  List<UserPlaces> userPlaces;
  String lang;
  String token;
  int accountType;

  MyLocation(
      {this.area, this.userPlaces, this.lang, this.token, this.accountType});
....

then MyLocation.userPlaces you can access your data

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.