title: Post List of Data to API in flutter
body: <p>I am currently working on an API and I want to post a list of data to the API.
  this is an e-commerce example, so I would need to pass the multiple items in the cart as per the line no, line no will auto-increment. and order should be posted with the same order ID but with a different order number.</p>
  <p>This is what the Json looks like -</p>
  <pre><code>    {
      &quot;VarFID&quot;: 1,
      &quot;VarCID&quot;: 1,
      &quot;VarAreaCode&quot;: 1,
      &quot;VarAge&quot;: 250,
      &quot;VarB&quot;: 20,
      &quot;VarF&quot;: 1,
      &quot;VarC&quot;: 256,
      &quot;VarF&quot;: 1,
      &quot;OrderLines&quot;: [
          {
              &quot;OrderID&quot;: &quot;SQ/19/10&quot;,
              &quot;Line No_&quot;: 1,
              &quot;Date&quot;: &quot;2019-04-02 00:00:00&quot;,
              &quot;Time&quot;: &quot;2019-04-02 11:38:48&quot;,
              &quot;No_&quot;: &quot;FAG-033&quot;,
              &quot;Name&quot;: &quot;LC GOLD&quot;,
              &quot;Quantity&quot;:000,
              &quot;Unit Price&quot;: 10000,
              &quot;Amount&quot;: 10000,
              &quot;Status&quot;: &quot;Under Processing&quot;,
              &quot;Remarks&quot;: &quot;VIKRAM&quot;,
              &quot;VariantCode&quot;:3
          },
          {
              &quot;OrderID&quot;: &quot;SQ/19/10&quot;,
              &quot;Line No_&quot;: 2,
              &quot;Date&quot;: &quot;2019-04-02 00:00:00&quot;,
              &quot;Time&quot;: &quot;2019-04-02 11:38:48&quot;,
              &quot;No_&quot;: &quot;F061&quot;,
              &quot;Name&quot;: &quot;LC S - I&quot;,
              &quot;Quantity&quot;: 00,
              &quot;Unit Price&quot;: 100,
              &quot;Amount&quot;: 300,
              &quot;Status&quot;: &quot;Under Processing&quot;,
              &quot;Remarks&quot;: &quot;VIKRAM &quot;,
              &quot;VariantCode&quot;:2
          }
  
      ]
  }
  </code></pre>
  <p>This is the code I am using to generate the array, the data is going through, but it is only posting one item/line and not both of them.</p>
  <pre><code>      void sendData2() async {
      mainModel = MainModel(
          VarFID: &quot;1&quot;,
          VarCID: &quot;1&quot;,
          VarAreaCode: &quot;1&quot;,
          VarAge: &quot;1&quot;,
          VarB: &quot;1&quot;,
          VarF: &quot;1&quot;,
          VarC: &quot;1&quot;,
          VarF: &quot;1&quot;,
          OrderLines: listOrderLines.OrderLines);
      var response = await http.post(
        Uri.https('softwareonus.com:8082', '/admindealerlist/'),
        headers: {&quot;Content-Type&quot;: &quot;application/json&quot;},
        body: json.encode(mainModel.toJson()),
      );
  
      print(&quot; Send Data 2 Response  : ${response.body}&quot;);
      print(&quot; Send Data 2 Response  : ${response.statusCode}&quot;);
    }
  
  </code></pre>
  <p>I have created model classes using JsonSerialazble</p>