HttpService class

Inheritance
  • Object
  • GetLifeCycle
  • DisposableInterface
  • GetxService
  • HttpService

Constructors

HttpService({required String baseUrl, Duration? connectTimeout, Duration? receiveTimeout, bool retryEnable = true, List<Interceptor>? interceptors, Map<String, dynamic>? proxyConfig})

Properties

baseUrl String
地址前缀
final
connectTimeout Duration?
连接超时赶时间
final
dio ↔ Dio
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
initialized bool
Checks whether the controller has already been initialized.
no setterinherited
interceptors List<Interceptor>?
基础拦截器
final
isClosed bool
Checks whether the controller has already been closed.
no setterinherited
onDelete → InternalFinalCallback<void>
Internal callback that starts the cycle of this controller.
finalinherited
onStart → InternalFinalCallback<void>
Called at the exact moment the widget is allocated in memory. It uses an internal "callable" type, to avoid any @overrides in subclases. This method should be internal and is required to define the lifetime cycle of the subclass.
finalinherited
proxyConfig Map<String, dynamic>?
代理配置
final
receiveTimeout Duration?
接收超时赶时间
final
retryEnable bool
重试开启
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

$configureLifeCycle() → void
inherited
cancelRequests({CancelToken? token}) → void
delete(String path, {dynamic data, Map<String, dynamic>? params, Options? options, CancelToken? cancelToken, bool refresh = false, bool noCache = !CACHE_ENABLE, String? cacheKey, bool cacheDisk = false, bool showToastOnError = true, bool showMask = false}) Future
restful delete 操作
download(String path, dynamic savePath, {ProgressCallback? onReceiveProgress, Map<String, dynamic>? queryParameters, CancelToken? cancelToken, bool deleteOnError = true, String lengthHeader = Headers.contentLengthHeader, dynamic data, Options? options}) Future
文件下载
get(String path, {Map<String, dynamic>? params, Options? options, CancelToken? cancelToken, bool refresh = false, bool noCache = !CACHE_ENABLE, String? cacheKey, bool cacheDisk = false, bool showToastOnError = true, bool showMask = false}) Future
restful get 操作
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onClose() → void
Called before onDelete method. onClose might be used to dispose resources used by the controller. Like closing events, or streams before the controller is destroyed. Or dispose objects that can potentially create some memory leaks, like TextEditingControllers, AnimationControllers. Might be useful as well to persist some data on disk.
inherited
onInit() → void
Called immediately after the widget is allocated in memory. You might use this to initialize something for the controller.
override
onReady() → void
Called 1 frame after onInit(). It is the perfect place to enter navigation events, like snackbar, dialogs, or a new route, or async request.
inherited
patch(String path, {dynamic data, Map<String, dynamic>? params, Options? options, CancelToken? cancelToken, bool refresh = false, bool noCache = !CACHE_ENABLE, String? cacheKey, bool cacheDisk = false, bool showToastOnError = true, bool showMask = false}) Future
restful patch 操作
post(String path, {Map<String, dynamic>? params, dynamic data, Options? options, CancelToken? cancelToken, bool refresh = false, bool noCache = !CACHE_ENABLE, String? cacheKey, bool cacheDisk = false, bool showToastOnError = true, bool showMask = false}) Future
restful post 操作
postForm(String path, {required Map<String, dynamic> params, Options? options, CancelToken? cancelToken, bool refresh = false, bool noCache = !CACHE_ENABLE, String? cacheKey, bool cacheDisk = false, bool showToastOnError = true, bool showMask = false}) Future
restful post form 表单提交操作
put(String path, {dynamic data, Map<String, dynamic>? params, Options? options, CancelToken? cancelToken, bool refresh = false, bool noCache = !CACHE_ENABLE, String? cacheKey, bool cacheDisk = false, bool showToastOnError = true, bool showMask = false}) Future
restful put 操作
setHeaders(Map<String, dynamic> map) → void
设置headers
toString() String
A string representation of this object.
inherited

Operators

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

Static Properties

to HttpService
no setter

Static Methods

register({required String baseUrl, Duration? connectTimeout, Duration? receiveTimeout, bool retryEnable = true, List<Interceptor>? interceptors, Map<String, dynamic>? proxyConfig, Widget? maskWidget}) Future<void>

Constants

CONNECT_TIMEOUT → const Duration
超时时间
RECEIVE_TIMEOUT → const Duration