IHttpConfig class abstract
http配置
- Implementers
Constructors
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
-
configBaseOptions(
) → BaseOptions -
配置通用的http请求选项BaseOptions
优先级最低,优先取
Api
#request
方法中配置的method和option -
configHttpResultErrorCode(
Map< String, dynamic> data) → String - 配置错误code
-
configHttpResultErrorMessage(
Map< String, dynamic> data) → String - 配置错误的描述信息
-
configHttpResultIsSuccess(
Map< String, dynamic> data) → bool -
配置http请求成功的条件 参考 DefaultHttpConfigImpl
data
请求的元数据 -
configHttps(
X509Certificate cert, String host, int port) → bool - 配置https,默认为true,表示不检验证书,
-
configInterceptors(
) → List< Interceptor> ? - 添加拦截器 公共请求头可以使用拦截器添加 拦截器队列的执行顺序是FIFO,先添加的拦截器先执行
-
configLoadingText(
) → String - 配置默认值:http加载提示文本
-
configLogEnable(
) → bool -
是否自动添加
LogInterceptors
默认日志拦截器,打印http请求响应相关的日志 -
getBaseUrl(
String url) → String? -
如果url中不包含baseUrl,请求前回调该方法获取baseUrl
优先级高于IHttpConfig#configBaseOptions方法配置的baseUrl
url
当前正在请求的接口url return: 返回null使用IHttpConfig#configBaseOptions方法配置的baseUrl -
hideLoading(
String url, int tag, bool isCancelled) → void -
请求完成,关闭加载框:
Api
#request
方法isShowLoading字段为true时,会回调该方法url
当前请求urltag
当前请求对应的tag,唯一isCancelled
当前请求是否已经取消,如果已经取消则不用关闭dialog -
isCancelableDialog(
) → bool - 配置默认值:加载中能否通过关闭加载弹窗取消请求
-
isCheckNetwork(
) → bool - 配置默认值:请求前是否校验网络连接 true:如果无网络,直接返回错误
-
isHttpRespTokenError(
Map< String, dynamic> data) → bool -
http请求失败时会回调该方法,判断是否是token失效导致的错误
errorBean
请求失败对象 -
isShowFailToast(
) → bool - 配置默认值:请求失败时是否自动显示toast提示错误
-
isShowLoading(
) → bool - 配置默认值:http请求时是否显示加载dialog
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
onTokenErrorCallback(
) → void -
token失效回调该方法
errorBean
请求失败对象 -
showLoading(
String url, int tag, CancelToken cancelToken, String loadingText, bool isCancelableDialog) → void -
http请求显示加载框:
Api
#request
方法isShowLoading字段为true时,会回调该方法
url
当前请求url
tag
当前请求对应的tag,唯一
cancelToken
用于加载框关闭时取消http请求
loadingText
加载提示提示
isCancelableDialog
请求过程中能否关闭加载框,默认false
#desc: 不提供默认的loading ,flutter 的dialog 需要context,而quick则不会保留context。 -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited