title: send array of array to post API in flutter
body: <p>I have an API that needed me sending an array of array to the backend the form of request body is</p>
  <pre><code>{
      &quot;pharmacy_id&quot; : 15,
      &quot;medicines&quot;: [{&quot;medicine_id&quot;: 500, &quot;amount&quot;: 2},{&quot;medicine_id&quot;: 520, &quot;amount&quot;: 5}],
      &quot;latitude&quot; : 24.2594,
      &quot;longitude&quot; : 27.654
  }
  </code></pre>
  <p>I thought that is a list of map so I make it as <code>List&lt;&lt;Map&lt;String,dynamic&gt;&gt;</code>
  and the result was</p>
  <p><code>[{&quot;medicine_id&quot;: 500, &quot;amount&quot;: 2},{&quot;medicine_id&quot;: 520, &quot;amount&quot;: 5}]</code></p>
  <p>but the response come as follow</p>
  <pre><code>value body is : {&quot;message&quot;:&quot;The given data was invalid.&quot;,&quot;errors&quot;:{&quot;medicines&quot;:[&quot;The medicines must be an array.&quot;]}}
  value.reasonPhrase is : Unprocessable Content
  value.statusCode is : 422
  </code></pre>
  <p>so my question is : how to send this data and in which form I should make it in ?</p>
  <p>my API post Function</p>
  <pre><code>Future&lt;void&gt; cartOrder({required String pharmacy_id,required int pharmID, required List&lt;Map&lt;String,dynamic&gt;&gt; medicines, String? coupon, required BuildContext context}) async{
      emit(HomeGetAboutUsLoadingState());
      await http.post(
          Uri.parse('${api}order/store'),
          body:{
            'pharmacy_id': pharmacy_id,
            'medicines': medicines,
            'latitude': latitude,
            'longitude': longitude,
            'coupon': coupon
          }, headers: {'Accept': 'application/json', 'Authorization' : 'Bearer ${CacheHelper.getData(key: 'token')}'
      }).then((value){
        oneOrderModel = OneOrderModel.fromJson(jsonDecode(value.body));
        print(&quot;value body is : ${value.body}&quot;);
        print(&quot;oneOrderModel is $oneOrderModel&quot;);
        print(&quot;value.reasonPhrase is : ${value.reasonPhrase}&quot;);
        print(&quot;value.statusCode is : ${value.statusCode}&quot;);
        print(&quot;cartOrder value is : $value&quot;);
        navigateFinalTo(context,const HomeDrawer());
        print(&quot;cart order value is : $value&quot;);
        print(&quot;cart order success&quot;);
        Fluttertoast.showToast(msg: &quot;تم إرسال طلبك بنجاح&quot;);
        print(&quot;load user order&quot;);
        UserOrders();
        print(&quot;user order loaded&quot;);
        int index = 0;
        myItems.forEach((element) {
          deleteRowCart(id: pharmID, index: index);
          index++;
        });
        print(&quot;my list item is empty now&quot;);
        emit(HomeGetAboutUsSuccessState());
      }).catchError((error){
        print(&quot;cart order error is : $error&quot;);
        emit(HomeGetAboutUsErrorState());
      });
    }
  </code></pre>
  <p>the list of medicines and thier amount is</p>
  <pre><code>var extractMap = cubit.myItems.map((element) =&gt; Map.fromEntries([
  MapEntry('medicine_id', element['medicineID']),
  MapEntry('amount', element['quantity']),])).toList();
  print(&quot;my order items is : $extractMap&quot;);
  extractMap.isNotEmpty ?
  cubit.cartOrder(context: context,
  pharmID: cubit.onePharmacyModel!.data!.id!.toInt(),
  pharmacy_id: cubit.onePharmacyModel!.data!.id!.toString(),
  medicines: extractMap,
  coupon: codeController.text.toString()
  ): Fluttertoast.showToast(msg: &quot;cart is empty&quot;);
      ```
  </code></pre>