title: How to retrieve dynamic values from Api request response
body: <p>I am receiving a dynamic response from my API, but I do not know how to retrieve it like inside data the fields are changing:</p>
  
  <pre><code>{
      "status": "ERROR",
      "data": {
          "email-common": "This email already exists."
      }
  }
  </code></pre>
  
  <p>Another time it might look like this:</p>
  
  <pre><code>{
      "status": "ERROR",
      "data": {
          "password": "passwords do not match"
      }
  }
  </code></pre>
  
  <p>I know the code in Java but in flutter I don't know how to do it. Idea can be get from this Java code</p>
  
  <pre><code>JSONObject data = result.getJSONObject("data");
  Iterator&lt;String&gt; keys = data.keys();
  
  while (keys.hasNext()) {
       String key = keys.next();
       Log.d("myTag", data.get(key).toString());
  }
  </code></pre>
  
  <p>If I do it for password then it's throwing errors, for the other one my question is whatever values there is I can retrieve it (dynamic retrieval) </p>
  
  <pre><code> Future&lt;Map&gt; getJson() async {
       String apiUrl = 'http://3.127.255.230/rest_ci/api/customers';
  
       Map&lt;String,String&gt; headers = {'Content-Type':'application/json','Authorization':'mykeyyyy'};
       final msg = jsonEncode({
           "username":"tesstestt123",
           "email":"khansdf@gmail.com",
           "password":"testtest",
           "confirm_password":"testtest",
       });
  
       http.Response response = await http
          .post(apiUrl,
                 headers: headers,
                 body: msg, );
  
       return json.decode(response.body); // returns a List type
  }
  
  void khan() async {
      getJson();
      String _body = "";
  
      Map _data = await getJson();
  
      _body = (_data['status']);
      print(_data);
  
      if (_body == 'ERROR') {
         setState(() {
        _isLoading = false;
      });
        print("$_data");
        showDialog(
            context: context,
            builder: (c) {
              return AlertDialog(
                title: Text("oops"),
                content: Text(_data['data']['password']),
                actions: &lt;Widget&gt;[
                  FlatButton(
                    onPressed: () {
                      Navigator.of(context).pop();
                    },
                    child: Text("Close"),
                  )
                ],
              );
            });
      }
  </code></pre>