sendRequest static method

Future<Response?>? sendRequest({
  1. required String requestId,
  2. required RequestType requestType,
  3. required String url,
  4. String token = '',
  5. String contentType = 'application/json',
  6. String? body,
  7. Map<String, String>? head,
})

Implementation

static Future<http.Response?>? sendRequest({
  required String requestId,
  required RequestType requestType,
  required String url,
  String token = '',
  String contentType = 'application/json',
  String? body,
  Map<String, String>? head,
}) async {
  try {
    final headers = head ?? _getHeaders(token, contentType);
    return await _createRequest(
      requestId: requestId,
      requestType: requestType,
      uri: Uri.parse(url),
      headers: headers,
      body: body,
    );
  } on SocketException {
    throw "No internet connection.";
  } on HandshakeException {
    throw "Connection terminated during handshake";
  } catch (e) {
    throw e.toString();
  }
}