request<T> method
Future<BaseModel>
request<T>(
- String path, {
- Map<
String, dynamic> ? params, - Object? data,
- dynamic tag,
- bool? loading,
- bool dataToJson = true,
- Options? options,
- ProgressCallback? onSendProgress,
- ProgressCallback? onReceiveProgress,
- CancelToken? cancelToken,
Implementation
Future<BaseModel> request<T>(
String path, {
Map<String, dynamic>? params,
Object? data,
dynamic tag,
bool? loading,
bool dataToJson = true,
Options? options,
ProgressCallback? onSendProgress,
ProgressCallback? onReceiveProgress,
CancelToken? cancelToken,
}) async {
assert(_singleton != null, '请先调用 initialize');
if (hasNetWork) return notNetWorkModel;
_addLoading(loading);
data = baseDioOptions.extraData?.call(path, data) ?? data;
final res = await dio.request<T>(path,
options: _mergeOptions(options, path),
onSendProgress: onSendProgress,
onReceiveProgress: onReceiveProgress,
params: baseDioOptions.extraParams?.call(path, params) ?? params,
cancelToken: cancelToken,
data: dataToJson ? jsonEncode(data) : data);
return _response(res, tag);
}