request method

Future<Response> request(
  1. String path, {
  2. bool showLoading = false,
  3. DioMethod method = DioMethod.get,
  4. Map<String, dynamic>? params,
  5. dynamic data,
  6. Options? options,
  7. CancelToken? cancelToken,
  8. ProgressCallback? onSendProgress,
  9. 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);
  }
}