post static method

Future post({
  1. required String path,
  2. int? port,
  3. required Map<String, dynamic> body,
  4. String? token,
})

Implementation

static Future<dynamic> post(
    {required String path, int? port, required Map<String, dynamic> body, String? token}) async {
  final Uri uri = DdxHttpRequest.generateUri(path: path, port: port);

  final Map<String, String> headers = DdxHttpRequest.generateHeaders(token: token);
  http.Request request =
      DdxHttpRequest.generateRequest(method: DdxHttpConst.method.post, headers: headers, uri: uri, body: body);
  DdxLogger.httpRequest(httpRequest: request);

  try {
    final streamedResponse = await request.send().timeout(DdxHttpConfig.networkTimeLimit);
    final result = await http.Response.fromStream(streamedResponse);
    return DdxHttpResponse.get(result);
  } on TimeoutException {
    DdxException.requestTimeout();
  } on DdxException {}
}