request static method

Future request(
  1. String url, {
  2. String method = XHttp.GET,
  3. Map<String, dynamic>? queryParameters,
  4. Map<String, dynamic>? data,
  5. bool isCancelWhiteList = false,
  6. dynamic resultDialogConfig,
  7. Options? options,
  8. void onSendProgress(
    1. int,
    2. int
    )?,
  9. void onReceiveProgress(
    1. int,
    2. int
    )?,
  10. String? msg,
  11. String? baseUrl,
})

Implementation

static Future request(
  String url, {
  String method = XHttp.GET,
  Map<String, dynamic>? queryParameters,
  Map<String, dynamic>? data,
  bool isCancelWhiteList = false,
  resultDialogConfig,
  Options? options,
  void Function(int, int)? onSendProgress,
  void Function(int, int)? onReceiveProgress,
  String? msg,
  String? baseUrl,
}) async {
  XHttp.getInstance(baseUrl: baseUrl, msg: msg);
  Response? response;
  try {
    response = await dio?.request(
      url,
      options: options ??
          Options(
              method: method, contentType: Headers.formUrlEncodedContentType),
      queryParameters: queryParameters,
      data: data,
      cancelToken: isCancelWhiteList ? whiteListCancelToken : cancelToken,
      onReceiveProgress: onReceiveProgress,
      onSendProgress: onSendProgress,
    );
    return response?.data;
  } catch (e) {
    _instance._catchOthersError(e);
  } finally {
    _instance._showResultDialog(
      response,
      resultDialogConfig ?? {'type': XHttp.DIALOG_TYPE_OTHERS},
    );
  }
}