post<T> method

Future post<T>(
  1. String url, {
  2. Map<String, dynamic>? params,
  3. Map<String, dynamic>? formData,
  4. Options? options,
  5. CancelToken? cancelToken,
  6. ProgressCallback? onSendProgress,
  7. ProgressCallback? onReceiveProgress,
  8. OnSuccess? onSuccess,
  9. OnFailed? onFailed,
  10. OnCommon? onCommon,
  11. dynamic bind,
})

POST 请求

@param url 请求地址
@param params 请求参数(可选)
@param options 请求额外设置,包括Header等(可选)
@param cancelToken 取消请求时使用的CancelToken(可选)
@param onSendProgress 请求上传进度回调方法(可选)
@param onReceiveProgress 请求响应进度回调方法(可选)
@param onSuccess 请求成功回调方法(可选)
@param onFailed 请求失败回调方法(可选)
@param onCommon 公共回调方法,成功和失败都会调用,在onSuccess和onFailed之前调用(可选)

Implementation

Future<dynamic> post<T>(
  String url, {
  Map<String, dynamic>? params,
  Map<String, dynamic>? formData,
  Options? options,
  CancelToken? cancelToken,
  ProgressCallback? onSendProgress,
  ProgressCallback? onReceiveProgress,
  OnSuccess? onSuccess,
  OnFailed? onFailed,
  OnCommon? onCommon,
  dynamic bind,
}) async {
  String uri = _handleUrl(url, params);
  Object? data = _handleParams(url, params);
  if (formData != null && formData.isNotEmpty) {
    uri = url;
    data = FormData.fromMap(formData);
  }
  return _client!
      .post<T>(
        uri,
        data: data,
        options: _bindCancelToken(options, bind),
        cancelToken: cancelToken,
        onSendProgress: onSendProgress,
        onReceiveProgress: onReceiveProgress,
      )
      ._handleCallback(onSuccess, onFailed, onCommon);
}