title: MYSQL in Flutter
body: <p>I have created a database on MYSQL server, now i want to read all data present in table and disolay it in Listview in Flutter, now I am able to raed all data and displayed it on console but in not able to parse that data into Listview.
  <a href="https://i.stack.imgur.com/ZBkDQ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZBkDQ.png" alt="Data from table."></a></p>
  
  <pre><code>Future&lt;List&lt;ItemCategory&gt;&gt; getCategory() async {
  try {
    http.Response response = await http.post(
        "https://***************.000webhostapp.com/*************.php",
    );
    print('getCategory Response: ${response.body}');
    if (response.body != null) {
      List&lt;ItemCategory&gt; list = parseResponse(response.body);
      return list;
    } else {
      return List&lt;ItemCategory&gt;();
    }
  } catch (e) {
    return List&lt;ItemCategory&gt;(); // return an empty list on exception/error
  }
    }
  
    List&lt;ItemCategory&gt; parseResponse(String responseBody) {
      final parsed = json.decode(responseBody).cast&lt;Map&lt;String, dynamic&gt;&gt;();
      return parsed.map&lt;ItemCategory&gt;((json) =&gt; ItemCategory.fromJson(json)).toList();
    }
  </code></pre>
  
  <p>here is flutter code i am tryying.</p>
  
  <p>and here is the Category class</p>
  
  <pre><code>class ItemCategory{
    int catID;
    String catName, catDesc;
    bool matched = false;
  
    ItemCategory({this.catID, this.catName, this.catDesc});
  
  
  
     factory ItemCategory.fromJson(Map &lt;String, dynamic&gt; json){
       return ItemCategory(
         catID: json['cat_id'] as int,
         catName: json['cat_name'] as String,
         catDesc: json['cat_desc'] as String
       );
     }
  }
  </code></pre>