android – How cann I send data to Server from Sqflite?-ThrowExceptions

Exception or error:

I am new in flutter I try to implement send data to server functionality data is related to products list actually data is stored in SQFLite Database. Normally I can send(post) data to server like this,


var data = {'userid': '1', 'name': 'john','mobile': '5577665544', 'email' : '','order_date': date,'user_type': 'Student'};

    var response = await, body: json.encode(data));

But I want to send cart data to server how can I send from local Database to Server. Now I am getting product into list like this.

void getCartList() {
    final Future<Database> dbFuture = databaseHelper.getDatabaseInstance();
    dbFuture.then((database) {
      Future<List<LocalCart>> cartList = databaseHelper.getAllProducts();
      cartList.then((productList) {
        setState(() {
          this.productList = productList;

Model Class

class LocalCart{

  String cartId;
  String title;
  String price;
  int quantity;

  LocalCart([this.cartId, this.title, this.price, this.quantity]);

  Map<String, dynamic> toMap() {

    var map = Map<String, dynamic>();
    if (cartId != null) {
      map['product_id'] = cartId;

    map['product_name'] = title;

    map['product_price'] = price;

    map['product_quantity'] = quantity;

    return map;

  LocalCart.fromMap(Map<String, dynamic> map) {

    this.cartId = map['product_id'];
    this.title = map['product_name'];
    this.price = map['product_price'];
    this.quantity = map['product_quantity'];

Can anyone help me please how can I send(post) data to server, thanks in advance.

How to solve:

Leave a Reply

Your email address will not be published. Required fields are marked *