post method

  1. @override
Future<HttpResponse> post({
  1. required String url,
  2. required String body,
  3. required Map<String, String> headers,
  4. Duration? timeout,
})
override

Sends a POST request and returns the raw status code and body.

timeout is advisory; implementations should honor it when supported and surface timeouts as exceptions rather than swallowing them.

Implementation

@override
Future<HttpResponse> post({
  required String url,
  required String body,
  required Map<String, String> headers,
  Duration? timeout,
}) async {
  final mergedHeaders = <String, String>{
    'Content-Type': 'application/json',
    ...headers,
  };

  final response = await http
      .post(Uri.parse(url), headers: mergedHeaders, body: body)
      .timeout(timeout ?? defaultTimeout);

  return HttpResponse(statusCode: response.statusCode, body: response.body);
}