get<T> method

Future<Response<T>> get<T>(
  1. String url, {
  2. Map<String, String>? headers,
  3. String? contentType,
  4. Map<String, dynamic>? query,
  5. Decoder<T>? decoder,
  6. ResponseInterceptor<T>? responseInterceptor,
})

Implementation

Future<Response<T>> get<T>(
  String url, {
  Map<String, String>? headers,
  String? contentType,
  Map<String, dynamic>? query,
  Decoder<T>? decoder,
  ResponseInterceptor<T>? responseInterceptor,
}) async {
  try {
    var response = await _performRequest<T>(
      () => _get<T>(url, contentType, query, decoder, responseInterceptor),
      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',
    ));
  }
}