flutter error : Class '_InternalLinkedHashMap<String, dynamic>' has no instance method 'toMap'. Receiver: _LinkedHashMap len:9 Tried calling: toMap()

flutter error : Class '_InternalLinkedHashMap<String, dynamic>' has no instance method 'toMap'. Receiver: _LinkedHashMap len:9 Tried calling: toMap()

当我尝试从管理仪表板更新订单状态时,尽管添加功能已成功发送到 firebase,但这是我的订单模型,但我还是这样做了,因为当我从 firebase 收到订单时出错告诉我 List 不是 List 的子类型, 我将 List 类型的购物车列表发送到 List cardItemList 并使函数添加并成功执行但更新函数执行该错误我不知道为什么以及添加和更新有什么不同我将静态列表发送到两个函数什么都没有更改状态除外

class NewOrderModel
{
  String? orderId;
  String? userName;
  double? totalPrice;
  double? shipping;
  double? total;
  String? phone;
  String? address;
  String? dateTime;
  String? productName;
  String? status;
  int? quantity;
  List<dynamic>? cardItemList;
  NewOrderModel({
    this.orderId,
    this.userName,
    this.totalPrice,
    this.shipping,
    this.total,
    this.address,
    this.phone,
    this.dateTime,
    this.cardItemList,
    this.quantity,
    this.productName,
    this.status,
  });

  NewOrderModel.fromJson(Map<String, dynamic>? json)
  {
    orderId = json!['orderId'];
    userName = json['userName'];
    totalPrice = json['totalPrice'];
    shipping = json['shipping'];
    total = json['total'];
    phone=json['phone'];
    address=json['address'];
    dateTime=json['dateTime'];
    cardItemList=json['cardItemList'];
    quantity=json['quantity'];
    productName=json['productName'];
    status=json['status'];
  }
  Map<String, dynamic> toMap()
  {
    return {
      'orderId':orderId,
      'userName': userName,
      'totalPrice': totalPrice,
      'shipping': shipping,
      'total': total,
      'phone': phone,
      'address': address,
      'dateTime': dateTime,
      'status': status,
      'productName': productName,
      'quantity': quantity,
      'cardItemList' : cardItemList?.map((e) => e.toMap()).toList()
    };
  }
}

这是更新函数

void updateStatusOfOrdres(String id,{
  required String status,
   int? quantity,
   String? productName,
   String? dateTime,
   String? phone,
   String? address,
   String? orderId,
   String? userName,
   double? totalPrice,
   double? total,
   double? shipping,
   List<dynamic>? cardItemList,
})
  {
    NewOrderModel model = NewOrderModel(
      status: status,
      quantity: quantity,
      productName:productName,
      dateTime: dateTime,
      address:address ,
      orderId: orderId,
      phone:phone ,
      shipping:shipping ,
      total: total,
      totalPrice: totalPrice,
      userName:userName,
      cardItemList:cardItemList ,
    );
    FirebaseFirestore.instance
        .collection('orders')
        .doc(id)
        .update(model.toMap())
        .then((value) {
      getOrders();
    }).catchError((error){
      emit(UpdateOrdersErrorState(error.toString()));
      print(error.toString());
    });
  }

这就是将函数调用到可重用组件中的方法 我发送了一个 NewOrderModel 列表,例如索引的 newOrder 到组件,我制作了这个可重用组件,因为我将订单分为三种状态(新的、已确认的、已取消的)每个状态都有一个屏幕及其列表

AdminCubit.get(context).updateStatusOfOrdres(
              AdminCubit.get(context).ordersNewId[index],
              status: 'canceled',
              userName:model.userName ,
              totalPrice: model.totalPrice,
              total:model.total ,
              shipping:model.shipping ,
              phone: model.phone,
              orderId: model.orderId,
              cardItemList: model.cardItemList,
              address: model.address,
              dateTime:model.dateTime,
              productName: model.productName,
              quantity: model.quantity,
            );

谢谢你帮助我

我终于通过这种方式解决了这个问题

void updateStatusOfOrdres(String id,{
  required String status,
   int? quantity,
   String? productName,
   String? dateTime,
   String? phone,
   String? address,
   String? orderId,
   String? orderNumber,
   String? userName,
   double? totalPrice,
   double? total,
   double? shipping,
   String? userEmail,
   List<dynamic>? cardItemList,
})
  {
    FirebaseFirestore.instance
        .collection('orders')
        .doc(id)
        .update({
      'orderId':orderId,
      'userName': userName,
      'totalPrice': totalPrice,
      'shipping': shipping,
      'total': total,
      'phone': phone,
      'address': address,
      'dateTime': dateTime,
      'status': status,
      'productName': productName,
      'quantity': quantity,
      'userEmail': userEmail,
      'orderNumber': orderNumber,
      'cardItemList' : cardItemList?.toList(),
    })
        .then((value) {
      getOrders();
    }).catchError((error){
      emit(UpdateOrdersErrorState(error.toString()));
      print(error.toString());
    });
  }