post static method
Implementation
static Future<Response> post(Uri url,
{Map<String, String>? headers,
Object? body,
Encoding? encoding,
Duration? timeout}) async {
var newHeader = _defaultHeaders(headers);
final effectiveTimeout = timeout ?? requestTimeout;
var client = http.Client();
try {
return await client
.post(url,
body: jsonEncode(body), encoding: encoding, headers: newHeader)
.timeout(effectiveTimeout, onTimeout: () {
client.close();
throw TimeoutException("POST request timed out.", effectiveTimeout);
});
} finally {
client.close();
}
}