class SaleQuotationComponentModel { SaleQuotationComponentModel({ required this.id, required this.createdAt, required this.updatedAt, required this.name, required this.componentSpecification, required this.unitId, required this.unitPrice, required this.remark, required this.isDelete, required this.unit, }); final int? id; final DateTime? createdAt; final DateTime? updatedAt; final String? name; final String? componentSpecification; final int? unitId; final double? unitPrice; final String? remark; final int? isDelete; final Unit? unit; factory SaleQuotationComponentModel.fromJson(Map json) { return SaleQuotationComponentModel( id: json["id"], createdAt: DateTime.tryParse(json["createdAt"] ?? ""), updatedAt: DateTime.tryParse(json["updatedAt"] ?? ""), name: json["name"], componentSpecification: json["componentSpecification"], unitId: json["unitId"], unitPrice: double.parse(json["unitPrice"]), remark: json["remark"], isDelete: json["isDelete"], unit: json["unit"] == null ? null : Unit.fromJson(json["unit"]), ); } Map toJson() => { "id": id, "createdAt": createdAt?.toIso8601String(), "updatedAt": updatedAt?.toIso8601String(), "name": name, "componentSpecification": componentSpecification, "unitId": unitId, "unitPrice": unitPrice, "remark": remark, "isDelete": isDelete, "unit": unit?.toJson(), }; } class Unit { Unit({ required this.id, required this.label, }); final int? id; final String? label; factory Unit.fromJson(Map json) { return Unit( id: json["id"], label: json["label"], ); } Map toJson() => { "id": id, "label": label, }; }