withTempFile((file) {
try
{
const content = 'Hellow World';
fetch(
url: 'https://httpbin.org/post',
method: FetchMethod.post,
data: FetchData.fromString(content),
saveToPath: file);
/// process the json response.
final map =
Parser(read(file).toList()).jsonDecode() as Map<String, dynamic>;
expect(map['data'] as String, equals(content));
expect(
(map['headers'] as Map<String, dynamic>)['Content-Type'] as String,
equals('text/plain'));
} on FetchException catch (e) {
print('Exception Thrown: ${e.errorCode} ${e.message}');
}
/// print the returned data including any errors.
if (exists(file)) {
print(read(file).toParagraph());
}
}, create: false);