request method
Future<Response>
request(
- String path, {
- bool showLoading = false,
- DioMethod method = DioMethod.get,
- Map<String, dynamic>? params,
- dynamic data,
- Options? options,
- CancelToken? cancelToken,
- ProgressCallback? onSendProgress,
- ProgressCallback? onReceiveProgress,
})
Implementation
Future<Response> request(
String path, {
bool showLoading = false,
DioMethod method = DioMethod.get,
Map<String, dynamic>? params,
data,
Options? options,
CancelToken? cancelToken,
ProgressCallback? onSendProgress,
ProgressCallback? onReceiveProgress,
}) async {
options ??= Options(method: method.value);
if (showLoading) EasyLoading.show(maskType: EasyLoadingMaskType.clear);
try {
Response response;
response = await _dio!.request(
path,
data: data,
queryParameters: params,
options: options,
cancelToken: cancelToken,
onSendProgress: onSendProgress,
onReceiveProgress: onReceiveProgress,
);
if (showLoading) EasyLoading.dismiss();
return response;
} on DioException catch (v) {
if (showLoading) EasyLoading.dismiss();
return Response(requestOptions: v.requestOptions, statusCode: -9999, statusMessage: v.message);
}
}