requestResponse method
需要异步调用的网络请求
path 接口地址
reqType 请求类型,默认是ReqType.get
params 请求参数,拼接在path后面的
respConfig 自定义请求配置,用来配置解析内容的自定义json字段
body 放在body中的请求参数
cancelToken 用来取消请求的标识,不需要自己处理可不传,api内部已经处理
cacheMode 缓存模式,默认CacheMode.ONLY_NETWORK,生效前提是HttpManagerinit时候已经传入了CacheConfig
cacheTime 缓存时长,单位毫秒,生效前提如上,没有传时默认使用CacheConfig的默认配置
customCacheKey 当前接口请求的自定义缓存key,生效前提如上,没有传入自动根据接口、参数生成缓存key
Implementation
Future<Response<dynamic>> requestResponse({
required String path,
ReqType reqType = ReqType.get,
Map<String, dynamic>? params,
RespConfig? respConfig,
Options? options,
Map<String, dynamic>? body,
CancelToken? cancelToken,
CacheMode? cacheMode = CacheMode.ONLY_NETWORK,
int? cacheTime,
String? customCacheKey,
}) async {
cancelToken = cancelToken?? CancelToken();
_cancelTokenList.add(cancelToken);
return HttpManager.getInstance().requestResponse(
path: path,
reqType: reqType,
params: params,
respConfig: respConfig,
options: options,
body: body,
cancelToken: cancelToken,
cacheMode: cacheMode,
cacheTime: cacheTime,
customCacheKey: customCacheKey);
}