request<T> method

Future<Response<T>> request<T>(
  1. String url,
  2. String method, {
  3. dynamic body,
  4. String? contentType,
  5. Map<String, String>? headers,
  6. Map<String, dynamic>? query,
  7. Decoder<T>? decoder,
  8. Progress? uploadProgress,
})

Implementation

Future<Response<T>> request<T>(
  String url,
  String method, {
  dynamic body,
  String? contentType,
  Map<String, String>? headers,
  Map<String, dynamic>? query,
  Decoder<T>? decoder,
  Progress? uploadProgress,
}) async {
  try {
    var response = await _performRequest<T>(
      () => _request<T>(
        url,
        method,
        contentType: contentType,
        query: query,
        body: body,
        decoder: decoder,
        uploadProgress: uploadProgress,
      ),
      headers: headers,
    );
    return response;
  } on Exception catch (e) {
    if (!errorSafety) {
      throw GetHttpException(e.toString());
    }
    return Future.value(Response<T>(
      statusText: 'Can not connect to server. Reason: $e',
    ));
  }
}