title: How to loop a list of maps from json api dart/flutter
body: <p>I have create a class model  to receive json data from API</p>
  <pre><code>class Competition {
    int id;
    String name;
    String code;
    String type;
    String emblem;
    Competition({
      required this.id,
      required this.name,
      required this.code,
      required this.type,
      required this.emblem,
    });
  
    factory Competition.fromJson(Map&lt;String, dynamic&gt; data) {
      return Competition(
        id: data[&quot;matches&quot;][0][&quot;competition&quot;]['id'],
        name: data[&quot;matches&quot;][0][&quot;competition&quot;]['name'],
        code: data[&quot;matches&quot;][0][&quot;competition&quot;]['code'],
        type: data[&quot;matches&quot;][0][&quot;competition&quot;]['type'],
        emblem: data[&quot;matches&quot;][0][&quot;competition&quot;]['emblem'],
      );
    }
  }
  </code></pre>
  <p>the code work properly, every time index [0] change the coming data change for the next competition details</p>
  <p>i want to make this index change automatically for fetching all data at one time, this index represent list data[&quot;matches&quot;].length</p>
  <p>My Api service look like</p>
  <pre><code>class ServiceApi {
        Future&lt;Competition &gt; getmatches() async {
          http.Response response = await http.get(
              Uri.parse('_url'),
              headers: {'X-Auth-Token': '_key'});
      String body = response.body;
      Map&lt;String, dynamic&gt; data = jsonDecode(body);
      Competition compitition = Competition.fromJson(data);
      int numberOfCompetition = data[&quot;matches&quot;].length;
       return matches;
    }
  }
  </code></pre>