MockAdapter class
Mock 适配器实现
用于测试的模拟适配器,可以配置模拟响应、错误和延迟
- Implemented types
Constructors
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- name → String
-
Gets the name of the adapter.
no setteroverride
-
requestHistory
→ List<
AdapterRequest> -
获取请求历史记录
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- version → String
-
Gets the version of the adapter.
no setteroverride
Methods
-
addInterceptor(
AdapterInterceptor interceptor) → void -
Adds an interceptor to the adapter.
override
-
cancel(
CancelToken token) → void -
Cancels an ongoing request.
override
-
clearHistory(
) → void - 清除请求历史记录
-
clearMocks(
) → void - 清除所有模拟配置
-
download(
AdapterRequest request, String savePath, {ProgressCallback? onProgress}) → Future< AdapterResponse> -
Downloads a file from the server.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
removeInterceptor(
AdapterInterceptor interceptor) → void -
Removes an interceptor from the adapter.
override
-
request(
AdapterRequest request) → Future< AdapterResponse> -
Executes an HTTP request.
override
-
setMockDelay(
String path, Duration delay) → void - 设置模拟延迟
-
setMockError(
String path, AdapterException error) → void - 设置模拟错误
-
setMockResponse(
String path, AdapterResponse response) → void - 设置模拟响应
-
toString(
) → String -
A string representation of this object.
inherited
-
upload(
AdapterRequest request, {ProgressCallback? onProgress}) → Future< AdapterResponse> -
Uploads data to the server.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited