toJson method
Converts the ResponseItemDTO to a JSON object.
This method can be used when making HTTP requests to convert the response item to a format that can be sent in the request.
Implementation
Map<String, dynamic> toJson() {
Map<String, dynamic> data = <String, dynamic>{};
data["message"] = message;
data["status"] = status;
if (item != null) {
data["item"] = (item! as BaseDTO).toJson();
}
if (hasError) {
data["hasError"] = hasError;
data["error"] = error;
if (required != null && required!.isNotEmpty) {
data["required"] = required!.map((e) => e.toJson());
}
}
return data;
}