toJson method
Converts the BaseDTO to a JSON object.
This method can be used when making HTTP requests to convert the DTO to a format that can be sent in the request.
Implementation
@override
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = super.toJson();
data['showInList'] = showInList;
data['showInHot'] = showInHot;
data['showInHome'] = showInHome;
data['sortIndex'] = sortIndex;
data['modelCode'] = modelCode;
data['hsCode'] = hsCode;
if (detail != null) {
data['detail'] = detail!.toJson();
}
if (prices != null) {
data['prices'] = prices!.map((v) => v.toJson()).toList();
}
if (photos != null) {
data['photos'] = photos!.map((v) => v.toJson()).toList();
}
if (sides != null) {
data['sides'] = sides!.map((v) => v.toJson()).toList();
}
if (stocks != null) {
data['stocks'] = stocks!.map((v) => v.toJson()).toList();
}
if (inStocks != null) {
data['inStocks'] = inStocks!.map((v) => v.toJson()).toList();
}
if (outStocks != null) {
data['outStocks'] = outStocks!.map((v) => v.toJson()).toList();
}
if (catalogs != null) {
data['catalogs'] = catalogs!.map((v) => v.toJson()).toList();
}
data['variant1'] = variant1;
data['variant2'] = variant2;
if (features != null) {
data['features'] = features!.map((v) => v.toJson()).toList();
}
if (tags != null) {
data['tags'] = tags!.map((v) => v.toJson()).toList();
}
return data;
}