sendRequest method
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',
);
}
}