NetworkManager class

单例模式

Constructors

NetworkManager()
factory

Properties

defaultOptions BaseOptions
默认的配置
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

cancel(CancelToken? cancelToken) → void
取消指定的请求
cancelAll() → void
取消所有请求
cancelList(List<CancelToken>? cancelTokenList) → void
取消指定的请求
downloadFile<T>(String url, dynamic savePath, {dynamic onReceiveProgress(int progress, int total)?, Options? options, Map<String, dynamic>? queryParameters}) Future<T>
下载文件, url 下载路径的地址 savePath 保存路径的地址 onReceiveProgress 下载进度回调
getDio() Dio
获取dio
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
request<T>(String url, {Map<String, dynamic>? params, String host = "", Method method = Method.Post, Options? options, CancelToken? cancelToken}) Future<T>
dio 网络请求 网络请求每个请求配置的优先级最高,其次才是默认配置 url 接口地址 params参数地址 host接口域名 options 配置信息 cancelToken接口取消token
setAdapter(HttpClientAdapter adapter) → void
setBaseOptions(BaseOptions options) → dynamic
设置自定义的BaseOptions
setInterceptor(Interceptor? interceptor) → void
创建全局的拦截器(默认拦截器) 判断拦截器是否已经加入,已经加入了就不会再次添加拦截器
setInterceptors(Interceptors interceptors) → void
创建全局的拦截器(默认拦截器)
toString() String
A string representation of this object.
inherited
upLoadFile<T>(String url, FormData formData, {dynamic onSendProgressCB(int send, int total)?, Options? options, Map<String, dynamic>? queryParameters}) Future<T>
上传文件 formData post上传 url 访问地址 fromFile see FormData FormData.fromMap({'file': await MultipartFile.fromFile('filePath./text2.txt', filename: 'text2.txt')} FormData.fromMap({'files': await MultipartFile.fromFile('filePath./text2.txt', filename: 'text2.txt')} onSendProgressCB 上传进度条回调 options dio请求设置可以设置请求头header等'Content-Type': 'multipart/form-data;BaseOptions queryParameters 请求参数,可以作用于带参数上传 e.g await MultipartFile.fromFile(File(filePath), "file"),

Operators

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

Static Properties

instance NetworkManager
no setter