title: Generic class in Flutter
body: <p>I have a common response structure from http request like this</p>
  <pre><code>class CommonResponse&lt;T&gt; {
    int total;
    List&lt;T&gt; data;
    bool success;
  
    CommonResponse({this.total, this.data, this.success});
  
    CommonResponse.fromJson(Map&lt;String, dynamic&gt; json) {
      total = json['total'];
      data = json['data'];
  
      success = json['success'];
    }
  
    Map&lt;String, dynamic&gt; toJson() {
      final Map&lt;String, dynamic&gt; data = new Map&lt;String, dynamic&gt;();
      data['total'] = this.total;
      data['data'] = this.data;
      data['success'] = this.success;
    }
  }
  </code></pre>
  <p>Now I need to parse the generic data. For example I am getting list of zones inside data object in <code>CommonResponse</code></p>
  <pre><code>class Zone {
    bool active;
    String id;
    String name;
  
    Zone({this.active, this.id, this.name});
  
    Zone.fromJson(Map&lt;String, dynamic&gt; json) {
      this.active = json['active'];
      this.id = json['id'];
      this.name = json['name'];
    }
  
    Map&lt;String, dynamic&gt; toJson() {
      final Map&lt;String, dynamic&gt; data = new Map&lt;String, dynamic&gt;();
      data['active'] = this.active;
      data['id'] = this.id;
      data['name'] = this.name;
    }
  }
  </code></pre>
  <p>How to get list of zones?</p>
  <pre><code>  var response = {
      &quot;data&quot;: [
        {
          &quot;active&quot;: true,
          &quot;created_on&quot;: &quot;2020-03-12T09:56:11+00:00&quot;,
          &quot;description&quot;: &quot;For Testing&quot;,
          &quot;id&quot;: &quot;b17627eb-8a39-4230-80fe-ebed77f7e0e2&quot;,
          &quot;name&quot;: &quot;Office&quot;,
          &quot;updated_on&quot;: &quot;2020-03-19T12:26:16+00:00&quot;
        }
      ],
      &quot;success&quot;: true,
      &quot;total&quot;: 1
    };
    CommonResponse&lt;Zone&gt; common = CommonResponse.fromJson(response);
    print(common.data);
  </code></pre>
  <p>This is what i tried. I am getting perfect response but am getting error getting list of <code>Zone</code>. Error is cannot convert <code>List&lt;dynamic&gt;</code> to <code>Zone</code>.</p>