title: How to parse List of maps Json in flutter?
body: <p><a href="https://i.stack.imgur.com/4RFyl.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4RFyl.png" alt="enter image description here"></a><a href="https://i.stack.imgur.com/HQgKV.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/HQgKV.png" alt="enter image description here"></a><a href="https://i.stack.imgur.com/6PCaY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6PCaY.png" alt="enter image description here"></a>I have one Json structure with three maps, one is list of products then total and tax. I have to parse this json structure in flutter. I created on model class. Now i am getting the error in type casting. </p>
  
  <p>How to solve this?</p>
  
  <p>JSON Structure: </p>
  
  <pre><code>{
    "products" : [
       {                  
         "cart_id": "7",      
       },          
       {                  
         "cart_id": "7",
       }     
    ],
    "total": 100,
    "tax": 100
  }
  </code></pre>
  
  <p>Model class : </p>
  
  <pre><code>class CartModel {   
      List&lt;Product&gt; produtcts;
      double total;
  
      CartModel({this.produtcts, this.total});
  
      factory CartModel.fromJson(Map&lt;String, dynamic&gt; json) {
          var list = json['products'] as List;
          print(list.runtimeType);
          List&lt;Product&gt; products = list.map((i) =&gt; 
             Product.fromJson(i)).toList();
  
          return CartModel(
              produtcts: products, total: json['total'],);
      }
  }
  
  class Product {
      String cartId;
  
      Product({this.cartId,});
  
      factory Product.fromJson(Map&lt;String, dynamic&gt; json) {
          return Product(     
              productId: json['cart_id'],
          );
      }
  }
  </code></pre>