title: How can I map items from json with http get method flutter?
body: <p>I`m trying to use an http get method in flutter, but my json is returned like this:</p>
  <pre><code>{&quot;items&quot;:[{&quot;id&quot;:1,&quot;nome&quot;:&quot;Ricardo&quot;,&quot;telefone&quot;:&quot;(14) 99797-5621&quot;}],&quot;hasMore&quot;:false,&quot;limit&quot;:25,&quot;offset&quot;:0,&quot;count&quot;:1,&quot;links&quot;:[{&quot;rel&quot;:&quot;self&quot;,&quot;href&quot;:&quot;http://172.16.30.120:8080/ords/apiteste/integrafoods/users&quot;},{&quot;rel&quot;:&quot;describedby&quot;,&quot;href&quot;:&quot;http://172.16.30.120:8080/ords/apiteste/metadata-catalog/integrafoods/item&quot;},{&quot;rel&quot;:&quot;first&quot;,&quot;href&quot;:&quot;http://172.16.30.120:8080/ords/apiteste/integrafoods/users&quot;}]}
  </code></pre>
  <p>And i`m trying to retrieve info this way:</p>
  <pre><code>Future&lt;void&gt; _loadUsers() async {
      final response = await http.get(
        Uri.parse(_url),
        headers: &lt;String, String&gt;{
          'Content-Type': 'application/json; charset=UTF-8',
        },
      );
      if (response.body == 'null') return;
      Map&lt;String, dynamic&gt; data = jsonDecode(response.body);
      data.forEach(
        (items, userData) {
          teste.add(
            AppUser(
              id: items,
              login: userData['login'],
              phoneNumber: userData['telefone'],
            ),
          );
        },
      );
      print(_teste.length);
    }
  </code></pre>
  <p>But it's not working, it throws error: &quot;[ERROR:flutter/lib/ui/ui_dart_state.cc(198)] Unhandled Exception: type 'String' is not a subtype of type 'int' of 'index'&quot;.</p>
  <p>But if i use code this way, it returns all parameters from the json:</p>
  <pre><code>Future&lt;void&gt; _loadUsers() async {
      final response = await http.get(
        Uri.parse(_url),
        headers: &lt;String, String&gt;{
          'Content-Type': 'application/json; charset=UTF-8',
        },
      );
      if (response.body == 'null') return;
      Map&lt;String, dynamic&gt; data = jsonDecode(response.body);
      data.forEach(
        (items, userData) {
          teste.add(
            AppUser(
              login: userData['items'].toString(),
            ),
          );
        },
      );
      print(_teste.length);
    }
  </code></pre>
  <p>How can i map this &quot;items&quot; json so i get each parameter separetadely?</p>
  <pre><code>class AppUser {
    // final String CPF;
    final String id;
    final String? login;
    final String? name;
    final String? email;
    final String? situation;
    final String? phoneNumber;
    final String? password;
    final String? inclusionDt;
    final String? inclusionUs;
    final String? altDt;
    final String? altUs;
    final String company;
  
    const AppUser({
      // required this.CPF,
      required this.id,
      this.login,
      this.name,
      this.email,
      this.situation,
      this.phoneNumber,
      this.password,
      this.inclusionDt,
      this.inclusionUs,
      this.altDt,
      this.altUs,
      this.company = 'GTFoods',
    });
  }
  
  </code></pre>