work library

Classes

BackgroundTransformer
The default Transformer for Dio.
BaseOptions
The base config for the Dio instance, used by Dio.options.
CancelToken
Controls cancellation of Dio's requests.
Completer<T>
A way to produce Future objects and to complete them later with a value or error.
Dio
Dio enables you to make HTTP requests easily.
DioMixin
ErrorInterceptorHandler
The handler for interceptors to handle error occurred during the request.
EventSink<T>
A Sink that supports adding errors.
FormData
A class to create readable "multipart/form-data" streams. It can be used to submit forms and file uploads to http server.
Future<T>
The result of an asynchronous computation.
FutureOr<T>
A type representing values that are either Future<T> or T.
Headers
The headers class for requests and responses.
HttpClientAdapter
HttpAdapter is a bridge between Dio and HttpClient.
HttpResponse
实际的Http响应数据
Interceptor
Interceptor helps to deal with RequestOptions, Response, and DioException during the lifecycle of a request before it reaches users.
Interceptors
A Queue-Model list for Interceptors.
InterceptorsWrapper
A helper class to create interceptors in ease.
ListParam<T>
Indicates a param being used as queries or form data, and how does it gets formatted.
LogInterceptor
LogInterceptor is used to print logs during network requests. It should be the last interceptor added, otherwise modifications by following interceptors will not be logged. This is because the execution of interceptors is in the order of addition.
MultipartFile
A file to be uploaded as part of a MultipartRequest. This doesn't need to correspond to a physical file.
MultiStreamController<T>
An enhanced stream controller provided by Stream.multi.
Options
Every request can pass an Options object which will be merged with Dio.options
QueuedInterceptor
Interceptor in queue.
QueuedInterceptorsWrapper
A helper class to create queued-interceptors in ease.
RedirectRecord
A record that records the redirection happens during requests, including status code, request method, and the location.
RequestInterceptorHandler
The handler for interceptors to handle before the request has been sent.
RequestOptions
The internal request option class that is the eventual result after BaseOptions and Options are composed.
Response<T>
The Response class contains the payload (could be transformed) that respond from the request, and other information of the response.
ResponseBody
The response wrapper class for adapters.
ResponseInterceptorHandler
The handler for interceptors to handle after respond.
Stream<T>
A source of asynchronous data events.
StreamConsumer<S>
Abstract interface for a "sink" accepting multiple entire streams.
StreamController<T>
A controller with the stream it controls.
StreamIterator<T>
An Iterator-like interface for the values of a Stream.
StreamSink<S>
A object that accepts stream events both synchronously and asynchronously.
StreamSubscription<T>
A subscription on events from a Stream.
StreamTransformer<S, T>
Transforms a Stream.
StreamTransformerBase<S, T>
Base class for implementing StreamTransformer.
StreamView<T>
Stream wrapper that only exposes the Stream interface.
SynchronousStreamController<T>
A stream controller that delivers its events synchronously.
SyncTransformer
If you want to custom the transformation of request/response data, you can provide a Transformer by your self, and replace the transformer by setting the Dio.transformer.
Timer
A countdown timer that can be configured to fire once or repeatedly.
Transformer
Transformer allows changes to the request/response data before it is sent/received to/from the server.
UploadFileInfo
上传文件时的包装格式
Work<D, T extends WorkData<D>>
任务流程的基本模型
WorkConfig
Work库全局网络客户端配置
WorkData<T>
Work返回的数据包装类
WorkFuture<D, T extends WorkData<D>>
任务执行专用Future,提供了取消功能
WorkRequestOptions
任务请求的全部配置信息
Zone
A zone represents an environment that remains stable across asynchronous calls.
ZoneDelegate
An adapted view of the parent zone.
ZoneSpecification
A parameter object with custom zone function handlers for Zone.fork.

Enums

DioExceptionType
The exception enumeration indicates what type of exception has happened during requests.
HttpMethod
Http请求类型
ListFormat
Specifies the array format (a single parameter with multiple parameter or multiple parameters with the same name). and the separator for array items.
ResponseType
Indicates which transformation should be applied to the response data.
WorkErrorType
Work的异常类型

Mixins

OptionsMixin
The mixin class for options that provides common attributes.

Extensions

FutureExtensions on Future<T>
Convenience methods on futures.
FutureIterable on Iterable<Future<T>>
FutureRecord2 on (Future<T1>, Future<T2>)
Parallel operations on a record of futures.
FutureRecord3 on (Future<T1>, Future<T2>, Future<T3>)
Parallel operations on a record of futures.
FutureRecord4 on (Future<T1>, Future<T2>, Future<T3>, Future<T4>)
Parallel operations on a record of futures.
FutureRecord5 on (Future<T1>, Future<T2>, Future<T3>, Future<T4>, Future<T5>)
Parallel operations on a record of futures.
FutureRecord6 on (Future<T1>, Future<T2>, Future<T3>, Future<T4>, Future<T5>, Future<T6>)
Parallel operations on a record of futures.
FutureRecord7 on (Future<T1>, Future<T2>, Future<T3>, Future<T4>, Future<T5>, Future<T6>, Future<T7>)
Parallel operations on a record of futures.
FutureRecord8 on (Future<T1>, Future<T2>, Future<T3>, Future<T4>, Future<T5>, Future<T6>, Future<T7>, Future<T8>)
Parallel operations on a record of futures.
FutureRecord9 on (Future<T1>, Future<T2>, Future<T3>, Future<T4>, Future<T5>, Future<T6>, Future<T7>, Future<T8>, Future<T9>)
Parallel operations on a record of futures.
WorkLifeCycleExtension on Work<D, T>
Work执行流程扩展,提供了任务执行能力

Constants

multipartFormData → const String
多分块提交格式

Properties

debugWork bool
是否开启debug模式,开启后会输出日志
getter/setter pair
workConfig WorkConfig
全局默认使用的WorkConfig配置
getter/setter pair
workConfigs Map<String, WorkConfig>
存放自定义的WorkConfig对象
final
workLog WorkLogger
work库的日志打印函数,可以覆盖
no getter

Functions

runZoned<R>(R body(), {Map<Object?, Object?>? zoneValues, ZoneSpecification? zoneSpecification, Function? onError}) → R
Runs body in its own zone.
runZonedGuarded<R>(R body(), void onError(Object error, StackTrace stack), {Map<Object?, Object?>? zoneValues, ZoneSpecification? zoneSpecification}) → R?
Runs body in its own error zone.
scheduleMicrotask(void callback()) → void
Runs a function asynchronously.
unawaited(Future<void>? future) → void
Explicitly ignores a future.
workFileToJsonConvert(dynamic file) → dynamic
用于json_annotation库序列化标记需要上传的文件类型参数转换

Typedefs

ControllerCallback = void Function()
Type of a stream controller's onListen, onPause and onResume callbacks.
ControllerCancelCallback = FutureOr<void> Function()
Type of stream controller onCancel callbacks.
CreatePeriodicTimerHandler = Timer Function(Zone self, ZoneDelegate parent, Zone zone, Duration period, void f(Timer timer))
The type of a custom Zone.createPeriodicTimer implementation function.
CreateTimerHandler = Timer Function(Zone self, ZoneDelegate parent, Zone zone, Duration duration, void f())
The type of a custom Zone.createTimer implementation function.
DefaultTransformer = SyncTransformer
DioError = DioException
DioError describes the exception info when a request failed.
DioErrorType = DioExceptionType
Deprecated in favor of DioExceptionType and will be removed in future major versions.
ErrorCallbackHandler = AsyncError? Function(Zone self, ZoneDelegate parent, Zone zone, Object error, StackTrace? stackTrace)
The type of a custom Zone.errorCallback implementation function.
ForkHandler = Zone Function(Zone self, ZoneDelegate parent, Zone zone, ZoneSpecification? specification, Map<Object?, Object?>? zoneValues)
The type of a custom Zone.fork implementation function.
HandleUncaughtErrorHandler = void Function(Zone self, ZoneDelegate parent, Zone zone, Object error, StackTrace stackTrace)
The type of a custom Zone.handleUncaughtError implementation function.
HeaderForEachCallback = void Function(String name, List<String> values)
The signature that iterates header fields.
HttpCall = Future<Response> Function()
Http执行器,每次调用都应该发起独立的新http请求并返回dioResponse
InterceptorErrorCallback = void Function(DioException error, ErrorInterceptorHandler handler)
The signature of Interceptor.onError.
InterceptorSendCallback = void Function(RequestOptions options, RequestInterceptorHandler handler)
The signature of Interceptor.onRequest.
InterceptorSuccessCallback = void Function(Response response, ResponseInterceptorHandler handler)
The signature of Interceptor.onResponse.
JsonDecodeCallback = FutureOr Function(String)
The callback definition for decoding a JSON string.
JsonEncodeCallback = FutureOr<String> Function(Object)
The callback definition for encoding a JSON object.
OnProgress = void Function(int current, int total)
进度监听器
PrintHandler = void Function(Zone self, ZoneDelegate parent, Zone zone, String line)
The type of a custom Zone.print implementation function.
ProgressCallback = void Function(int count, int total)
The type of a progress listening callback when sending or receiving data.
RegisterBinaryCallbackHandler = ZoneBinaryCallback<R, T1, T2> Function<R, T1, T2>(Zone self, ZoneDelegate parent, Zone zone, R f(T1 arg1, T2 arg2))
The type of a custom Zone.registerBinaryCallback implementation function.
RegisterCallbackHandler = ZoneCallback<R> Function<R>(Zone self, ZoneDelegate parent, Zone zone, R f())
The type of a custom Zone.registerCallback implementation function.
RegisterUnaryCallbackHandler = ZoneUnaryCallback<R, T> Function<R, T>(Zone self, ZoneDelegate parent, Zone zone, R f(T arg))
The type of a custom Zone.registerUnaryCallback implementation function.
RequestEncoder = FutureOr<List<int>> Function(String request, RequestOptions options)
The type of a request encoding callback.
ResponseDecoder = FutureOr<String?> Function(List<int> responseBytes, RequestOptions options, ResponseBody responseBody)
The type of a response decoding callback.
RunBinaryHandler = R Function<R, T1, T2>(Zone self, ZoneDelegate parent, Zone zone, R f(T1 arg1, T2 arg2), T1 arg1, T2 arg2)
The type of a custom Zone.runBinary implementation function.
RunHandler = R Function<R>(Zone self, ZoneDelegate parent, Zone zone, R f())
The type of a custom Zone.run implementation function.
RunUnaryHandler = R Function<R, T>(Zone self, ZoneDelegate parent, Zone zone, R f(T arg), T arg)
The type of a custom Zone.runUnary implementation function.
ScheduleMicrotaskHandler = void Function(Zone self, ZoneDelegate parent, Zone zone, void f())
The type of a custom Zone.scheduleMicrotask implementation function.
ValidateStatus = bool Function(int? status)
The type of a response status code validate callback.
WorkLogger = void Function(String tag, String? message, [Object? data])
输出日志函数
WorkRequest = Future<HttpCall> Function(String tag, WorkRequestOptions options)
网络请求生成器
ZoneBinaryCallback<R, T1, T2> = R Function(T1, T2)
ZoneCallback<R> = R Function()
ZoneUnaryCallback<R, T> = R Function(T)

Exceptions / Errors

AsyncError
An error and a stack trace.
DeferredLoadException
Thrown when a deferred library fails to load.
DioException
DioException describes the exception info when a request failed.
NotNullableError<T>
A TypeError thrown by _checkNotNullable.
ParallelWaitError<V, E>
Error thrown when waiting for multiple futures, when some have errors.
TimeoutException
Thrown when a scheduled timeout happens while waiting for an async result.
WorkException
任务的异常类型