HttpUtil class

dio的封装

Constructors

HttpUtil()

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

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

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

Static Properties

dio Dio?
no setter

Static Methods

addHeader(Map<String, dynamic> header) → void
will auto override the same header
addInterceptor(InterceptorsWrapper interceptor) → void
assetDio() → void
delete(String url, Map<String, dynamic> params) Future<Map<String, dynamic>?>
delete请求
download(String url, String savePath, ProgressCallback? onReceiveProgress, {bool newClient = false}) Future<Response?>
下载文件
get(String url, {Map<String, dynamic>? params}) Future<Map<String, dynamic>?>
get请求
getCode(Map? res) String?
getData(Map? res) → dynamic
getMsg(Map? res) String?
init({int timeout = 15, String baseUrl = "", String? codeField, String? dataField, String? msgField, String? successCode, String? tokenHeaderName, Function? tokenCreator, Map<String, dynamic>? header, dynamic onHookResponse(dynamic)?}) → void
isSuccess(Map? map) bool
post(String url, {Map<String, dynamic>? params}) Future<Map<String, dynamic>?>
post请求,json编码
postFile(String url, File file) Future<Map<String, dynamic>?>
直传文件
postForm(String url, {Map<String, dynamic>? params, ProgressCallback? onSendProgress}) Future<Map<String, dynamic>?>
post请求,form编码 如需上传文件,则传入MultipartFile类型,如:
put(String url, Map<String, dynamic> params) Future<Map<String, dynamic>?>
put请求
putFile(String url, File file) Future<Map<String, dynamic>?>
直传文件