title: Fetch complex format data in list with dart language
body: <p>I'm just trying to fetch data via api in list but getting exception while debugging <code>Class '_InternalLinkedHashMap&lt;String, dynamic&gt;' has no instance method 'cast' with matching arguments.</code></p>
  
  <p>Here is my demo <a href="https://www.googleapis.com/books/v1/volumes?q=%7Bhttp%7D" rel="nofollow noreferrer">json_api</a>.</p>
  
  <p>First I created model class for data which I'm getting then decleared variables according to api data.
  Then created method to fetch data in the type of list of Model class objects.
  then created Widget tree and add StreamBuilder with the list type model class objects, to display data.</p>
  
  <p><strong>CODE:</strong></p>
  
  <p><strong>Model Class:</strong></p>
  
  <pre><code>
  class Results {
    String kind;
    List&lt;Item&gt; items;
    int totalItems;
    Results({
      this.kind,
      this.items,
      this.totalItems,
    });
    factory Results.fromJson(Map&lt;String, dynamic&gt; json) =&gt; new Results(
      kind: json["kind"],
      items: new List&lt;Item&gt;.from(json["items"].map((x) =&gt; Item.fromJson(x))),
      totalItems: json["totalItems"],
    );
  
    Map&lt;String, dynamic&gt; toJson() =&gt; {
      "kind": kind,
      "items": new List&lt;dynamic&gt;.from(items.map((x) =&gt; x.toJson())),
      "totalItems": totalItems,
    };
  }
  
  
  class Item {
    String id;
    String kind;
    String selfLink;
  
    Item({
      this.id,
      this.kind,
      this.selfLink,
    });
  
    factory Item.fromJson(Map&lt;String, dynamic&gt; json) =&gt; new Item(
      id: json["id"],
      kind: json["kind"],
      selfLink: json["selfLink"],
    );
  
    Map&lt;String, dynamic&gt; toJson() =&gt; {
      "id": id,
      "kind": kind,
      "selfLink": selfLink,
    };
  }
  </code></pre>
  
  <p><strong>Method for get data in list of Model class objects:</strong></p>
  
  <pre><code>Future&lt;List&lt;Results&gt;&gt; fetchData()async{
     List&lt;Results&gt; results = new List&lt;Results&gt;();
     final response = await http.get(url);
     if(response.statusCode == 200 || json !=null){
       List jsonParsed = json.decode(response.body).cast&lt;Map&lt;String, dynamic&gt;&gt;();
       for (int i = 0; i &lt; jsonParsed.length; i++) {
         results.add(new Results.fromJson(jsonParsed[i]));
       }
      return results;
     }else{
       print('Request failed with status: ${response.statusCode}');
       Fluttertoast.showToast(msg: "Request failed with status: ${response.statusCode}");
       throw Exception('Failed to load post');
     }
   }
  </code></pre>
  
  <p><strong>My Widget Tree with StreamBuilder:</strong></p>
  
  <pre><code>
  body:  Center(
         child:FutureBuilder&lt;List&lt;Results&gt;&gt;(
           future:fetchData(),
           builder: (context, snapshot){
             if(snapshot.hasData){
               return 
               //Center(child:Text(snapshot.data.items[0].id) ,);
                ListView.builder(
                 itemCount: snapshot.data.length,
                 itemBuilder: (context, int i){
                   return Column(
                    children: &lt;Widget&gt;[
                      ListTile(
                       leading: CircleAvatar(
                         child: Text(snapshot.data[i].items[i].id),
                       ),
                       title: Text(snapshot.data[i].totalItems.toString()),
                       subtitle: Text(snapshot.data[i].kind) ,
                      ),
                      Divider(color: Colors.grey,)
                    ],
                   );
                 },
               );
             }else if(snapshot.hasError){
               return Center(child: Text("${snapshot.error}"),);
             }else{
               return Center(child: CircularProgressIndicator(),);
             }
           },
         ),
       ),
  </code></pre>
  
  <p>Where Am i doing wrong.</p>