getCurlInputBody method
Encodes the input body data for a cURL command.
If the data is of type FormData, it converts the fields to a URL-encoded
string. Otherwise, it encodes the data as JSON.
Returns a String representing the encoded body data.
Implementation
String getCurlInputBody(dynamic data) {
try {
if (data is FormData) {
final formData =
data.fields.map((e) => '${e.key}=${e.value}').join('&');
return formData;
} else {
final res = json.encode(data);
return res;
}
} catch (e) {
return '';
}
}