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