getQuery<T extends ResponseBase> method

  1. @protected
Future<T> getQuery<T extends ResponseBase>({
  1. required RequestBase request,
  2. required T mapper(
    1. Map<String, dynamic>,
    2. Response response
    ),
  3. T orElse(
    1. dynamic,
    2. Response response
    )?,
  4. Options? options,
  5. bool cancelOnDispose = true,
  6. int expectedStatusCode = 200,
  7. bool allowCache = true,
})

Perform a query using the "GET" method. The query parameters are extracted from request Use mapper to map the json response Optionally you can use the orElse to map other kind of response Optionally you can specify options to pass to Dio cancelOnDispose lets you cancel the request if this service is disposed expectedStatusCode to check the result of the request set allowCache to true to skip the expectedStatusCode check when the response is a cached one (HTTP code 304)

Implementation

@protected
Future<T> getQuery<T extends ResponseBase>({
  required RequestBase request,
  required T Function(Map<String, dynamic>, Response response) mapper,
  T Function(dynamic, Response response)? orElse,
  Options? options,
  bool cancelOnDispose = true,
  int expectedStatusCode = 200,
  bool allowCache = true,
}) async {
  final performer = () => dioInstance.get(
        request.endpoint,
        queryParameters: request.toJson(),
        options: options,
        cancelToken: cancelOnDispose ? getNextToken() : null,
      );
  return _perform(performer, mapper, orElse, expectedStatusCode, allowCache);
}