BaseApi class

Constructors

BaseApi.new()

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

cancelRequest(CancelToken cancelToken) → void
取消某个网络请求
cancelRequests() → void
取消所有未完成的网络请求
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
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}) Future<Response>
需要异步调用的网络请求 path 接口地址 reqType 请求类型,默认是ReqType.get params 请求参数,拼接在path后面的 respConfig 自定义请求配置,用来配置解析内容的自定义json字段 body 放在body中的请求参数 cancelToken 用来取消请求的标识,不需要自己处理可不传,api内部已经处理 cacheMode 缓存模式,默认CacheMode.ONLY_NETWORK,生效前提是HttpManagerinit时候已经传入了CacheConfig cacheTime 缓存时长,单位毫秒,生效前提如上,没有传时默认使用CacheConfig的默认配置 customCacheKey 当前接口请求的自定义缓存key,生效前提如上,没有传入自动根据接口、参数生成缓存key
requestWithFuture<T>({required String path, required OnFromJson<T>? onFromJson, 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}) Future<BaseResp<T>>
需要异步调用的网络请求 path 接口地址 onFromJson 解析Json的方法回调 reqType 请求类型,默认是ReqType.get params 请求参数,拼接在path后面的 respConfig 自定义请求配置,用来配置解析内容的自定义json字段 body 放在body中的请求参数 cancelToken 用来取消请求的标识,不需要自己处理可不传,api内部已经处理 cacheMode 缓存模式,默认CacheMode.ONLY_NETWORK,生效前提是HttpManagerinit时候已经传入了CacheConfig cacheTime 缓存时长,单位毫秒,生效前提如上,没有传时默认使用CacheConfig的默认配置 customCacheKey 当前接口请求的自定义缓存key,生效前提如上,没有传入自动根据接口、参数生成缓存key
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited