title: Flutter get " type 'List<dynamic>' is not a subtype of type 'Map<String, dynamic>' in type cast error
body: <p>Out webserver return this result as:</p>
  
  <pre><code>[
    {
      "id": 1,
      "user_id": 10,
      "title": "xxxxxxx",
      "description": "xxxx",
      "type": "post",
      "featured_images": "",
      "slug": "xxxxxxxxx",
      "lang": "xx",
      "visit": 0,
      "click": 0,
      "state": 1,
      "created_at": "xxxxx",
      "updated_at": "xxxxx",
      "categories": [
        {
          "id": 9,
          "title": "xxxx",
          "lang": "fa",
          "parent": 0,
          "click": 0,
          "image": "",
          "created_at": "xxxxx",
          "updated_at": "xxxx",
          "pivot": {
            "contents_id": 1,
            "content_categories_id": 9
          }
        }
      ]
    }
  ]
  </code></pre>
  
  <p>and i make this structure class to parse it</p>
  
  <pre><code>part 'contents_model.g.dart';
  
  @JsonSerializable(nullable: false)
  class ContentsModel {
    int id;
    @JsonKey(name: 'post_id')
    int postId;
    String title;
    String description;
    String type;
    @JsonKey(name: 'featured_images')
    String featuredImages;
    String slug;
    String lang;
    int visit;
    int click;
    int state;
    @JsonKey(name: 'createdAt')
    String createdAt;
    @JsonKey(name: 'updatedAt')
    String updatedAt;
    @JsonKey(name:'categories')
    CategoriesModel categories;
  
    ContentsModel(this.id, this.postId, this.title, this.description, this.type, this.featuredImages, this.slug, this.lang, this.visit, this.click, this.state, this.createdAt, this.updatedAt, this.categories);
  
    factory ContentsModel.fromJson(Map&lt;String,dynamic&gt; json)=&gt;_$ContentsModelFromJson(json);
    Map&lt;String,dynamic&gt; toJson()=&gt;_$ContentsModelToJson(this);
  }
  
  
  part 'categories_model.g.dart';
  
  @JsonSerializable(nullable: true)
  class CategoriesModel {
    int id;
    String title;
    String lang;
    int parent;
    int click;
    String image;
    @JsonKey(name: 'created_at')
    String createdAt;
    @JsonKey(name: 'updated_at')
    String updatedAt;
  
    CategoriesModel(this.id, this.title, this.lang, this.parent, this.click, this.image, this.createdAt, this.updatedAt);
  
    factory CategoriesModel.fromJson(Map&lt;String,dynamic&gt; json)=&gt;_$CategoriesModelFromJson(json);
    Map&lt;String,dynamic&gt; toJson()=&gt;_$CategoriesModelToJson(this);
  }
  </code></pre>
  
  <p>now when i get data from server successful i can't return that, for example:</p>
  
  <pre><code>  Future&lt;List&lt;ContentsModel&gt;&gt; getContents() async {
      final response = await http.get(Constants.getContents);
      if (response.statusCode == 200) {
        final responseString = jsonDecode(response.body);
        try {
               List&lt;ContentsModel&gt; responses = 
                     responseString.map((j) =&gt;
                          ContentsModel.fromJson(j)).toList();
               return responses;
        }catch(error){
          print('Error:  $error');
          return null;
        }
      } else {
        throw Exception('error fetche contents');
      }
    }
  </code></pre>
  
  <p>for this line of code:</p>
  
  <p><code>return responseString.map&lt;List&lt;ContentsModel&gt;&gt;((json) =&gt; ContentsModel.fromJson(json)).toList();</code></p>
  
  <p>i get this error:</p>
  
  <blockquote>
    <p>type 'List' is not a subtype of type 'Map'
    in type cast</p>
  </blockquote>