sendRequest method

Future<StateFlowResponse> sendRequest(
  1. String path,
  2. HttpMethod method, {
  3. Map<String, String>? headers,
  4. dynamic body,
  5. List<MultipartFile>? files,
})

Implementation

Future<StateFlowResponse> sendRequest(
  String path,
  HttpMethod method, {
  Map<String, String>? headers,
  dynamic body,
  List<MultipartFile>? files,
}) async {
  try {
    final response = await _sendRequest(path, method,
        headers: headers, body: body, files: files);
    final responseBody = await response.transform(utf8.decoder).join();

    return StateFlowResponse(
      response.statusCode,
      responseBody,
      response.reasonPhrase,
    );
  } catch (e) {
    return StateFlowResponse(
      500,
      'An error occurred: $e',
      'Internal Server Error',
    );
  }
}