post<T> method

Future<BasicModel> post<T>(
  1. String path, {
  2. Map<String, dynamic>? params,
  3. Object? data,
  4. bool dataToJson = true,
  5. dynamic tag,
  6. bool? loading,
  7. dynamic options,
  8. dynamic onSendProgress,
  9. dynamic onReceiveProgress,
  10. dynamic cancelToken,
})

Implementation

Future<BasicModel> post<T>(
  String path, {
  Map<String, dynamic>? params,
  Object? data,
  bool dataToJson = true,
  dynamic tag,
  bool? loading,
  Options? options,
  ProgressCallback? onSendProgress,
  ProgressCallback? onReceiveProgress,
  CancelToken? cancelToken,
}) async {
  assert(_singleton != null, '请先调用 initialize');
  if (hasNetWork) return notNetWorkModel;
  _addLoading(loading);
  data = basicDioOptions.extraData?.call(path, data) ?? data;

  final res = await dio.post<T>(path,
      options: _initBasicOptions(options, path),
      params: basicDioOptions.extraParams?.call(path, params) ?? params,
      onReceiveProgress: onReceiveProgress,
      onSendProgress: onSendProgress,
      cancelToken: cancelToken,
      data: dataToJson ? jsonEncode(data) : data);
  return _response(res, tag);
}