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['title'] = title;
data['content'] = content;
if (photos != null) {
data['photos'] = photos!.map((v) => v.toJson()).toList();
}
if (tags != null) {
data['tags'] = tags!.map((v) => v.toJson()).toList();
}
return data;
}