getQuery<T extends ResponseBase> method
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);
}