smart_dio library

smart_dio 2.0 - Barrel Export

Classes

BackgroundTransformer
The default Transformer for Dio.
BackupCacheStore
A store saving responses in a dedicated primary store and secondary store.
BaseOptions
A set of base settings for each Dio(). BaseOptions and Options will be merged into one RequestOptions before sending the requests. See Options.compose.
BaseRequest
Abtract request adapter
BaseResponse
Abtract response adapter
CacheCipher
CacheControl
Cache-Control header subset representation
CacheOptions
Options to apply to handle request and cache behaviour.
CachePlugin
缓存插件
CacheResponse
Response representation from cache store.
CacheStore
Definition of store
CacheStrategy
Cache strategy result containing either a request or a cached response but not both.
CacheStrategyFactory
A factory class for creating cache strategies based on HTTP requests and responses.
CancelToken
Controls cancellation of Dio's requests.
ConfigurableErrorLocalizer
可配置本地化器(支持部分覆盖)
DefaultErrorLocalizer
默认中文本地化器
Dio
Dio enables you to make HTTP requests easily.
DioCacheInterceptor
Cache interceptor
DioMixin
ErrorInterceptorHandler
The handler for interceptors to handle error occurred during the request.
ErrorKey
错误键,用于精确定位错误消息
FormData
A class to create readable "multipart/form-data" streams. It can be used to submit forms and file uploads to http server.
FusedTransformer
A Transformer that has a fast path for decoding UTF8-encoded JSON. If the response is utf8-encoded JSON and no custom decoder is specified in the RequestOptions, this transformer is significantly faster than the default SyncTransformer and the BackgroundTransformer. This improvement is achieved by using a fused Utf8Decoder and JsonDecoder to decode the response, which is faster than decoding the utf8-encoded JSON in two separate steps, since Dart uses a special fast decoder for this case. See https://github.com/dart-lang/sdk/blob/5b2ea0c7a227d91c691d2ff8cbbeb5f7f86afdb9/sdk/lib/_internal/vm/lib/convert_patch.dart#L40
HeaderPlugin
固定头部插件
Headers
The headers class for requests and responses.
HttpClientAdapter
HttpAdapter is a bridge between Dio and HttpClient.
HttpDate
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.
LoggerPlugin
日志插件
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.
MemCacheStore
A store saving responses in a dedicated memory LRU map.
Middleware
中间件抽象接口
MiddlewareChain
中间件执行链
MultipartFile
An upload content that is a part of MultipartRequest. This doesn't need to correspond to a physical file.
Options
The configuration for a single request. BaseOptions and Options will be merged into one RequestOptions before sending the requests. See Options.compose.
ParamsPlugin
固定参数插件
QueuedInterceptor
Interceptor in queue.
QueuedInterceptorsWrapper
A helper class to create QueuedInterceptor in ease.
RedirectRecord
A record that records the redirection happens during requests, including status code, request method, and the location.
RequestContext
请求上下文
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.
RetryPlugin
重试插件
SmartClientManager
SmartDio 客户端管理器
SmartConfig
SmartDio 全局配置(不可变)
SmartDio
SmartDio 门面 API
SmartDioContentType
SmartDioUtil
Object Util.
SmartErrorLocalizer
错误消息本地化器接口
SmartPlugin
SmartDio 插件基类
SmartRequest
请求 DTO
SmartResponse<T>
响应包装类
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.
TalkerDioLogger
Dio http client logger on Talker base
TalkerDioLoggerSettings
TalkerDioLogger settings and customization
Transformer
Transformer allows changes to the request/response data before it is sent/received to/from the server.

Enums

CachePolicy
Policy to handle request behaviour.
CachePriority
Cache priority.
DioExceptionType
The exception enumeration indicates what type of exception has happened during requests.
FileAccessMode
The file access mode when downloading a file, corresponds to a subset of dart:io::FileMode.
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.
TimeoutPhase
超时阶段枚举

Mixins

OptionsMixin
The mixin class for options that provides common attributes.

Constants

ageHeader → const String
cacheControlHeader → const String
contentLocationHeader → const String
contentTypeHeader → const String
dateHeader → const String
etagHeader → const String
expiresHeader → const String
extraCacheKey → const String
Cache key available in Response
extraFromNetworkKey → const String
Available in Response if coming from network.
extraKey → const String
extraRequestSentDateKey → const String
Available in RequestOptions to know when request has been sent.
ifModifiedSinceHeader → const String
ifNoneMatchHeader → const String
jsonContentType → const String
lastModifiedHeader → const String
varyHeader → const String

Properties

token RegExp
An HTTP token.
final
whitespace RegExp
A regular expression matching any number of _lws productions in a row.
final

Functions

defaultDioExceptionReadableStringBuilder(DioException e) String
The default implementation of building a readable string of DioException.
getDateHeaderValue(String? headerValue) DateTime?
getExpiresHeaderValue(String? headerValue) DateTime?
isCacheCheckAllowed(int? statusCode, CacheOptions cacheOptions) bool
Checks if we can try to resolve cached response against given statusCode and cacheOptions.
staticMessage(String message) MessageTemplate
创建简单的静态消息模板
template(String pattern) MessageTemplate
创建字符串模板辅助函数

Typedefs

CacheKeyBuilder = String Function({Object? body, Map<String, String>? headers, required Uri url})
Key builder to customize keys.
Decrypt = Future<List<int>> Function(List<int> bytes)
Decrypt content/headers method.
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.
DioExceptionReadableStringBuilder = String Function(DioException e)
The readable string builder's signature of DioException.readableStringBuilder.
DioMediaType = MediaType
The type (alias) for specifying the content-type of the MultipartFile.
Encrypt = Future<List<int>> Function(List<int> bytes)
Encrypt content/headers method.
HeaderForEachCallback = void Function(String name, List<String> values)
The signature that iterates header fields.
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.
MessageTemplate = String Function(SmartError error, Map<String, Object?> context)
消息模板函数类型
OnError = FutureOr<void> Function(RequestContext ctx, SmartError error)
请求错误回调
OnFinish = FutureOr<void> Function(RequestContext ctx)
请求结束回调(无论成功失败)
OnStart = FutureOr<void> Function(RequestContext ctx)
请求开始回调
OnSuccess<T> = FutureOr<void> Function(RequestContext ctx, SmartResponse<T> response)
请求成功回调
ProgressCallback = void Function(int count, int total)
The type of a progress listening callback when sending or receiving data.
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.
ShouldRetry = bool Function(SmartError error)
重试判断函数类型
ValidateStatus = bool Function(int? status)
The type of a response status code validate callback.

Exceptions / Errors

BusinessError
业务逻辑错误
CancelError
请求取消错误
CertificateError
SSL 证书错误
DioException
DioException describes the exception info when a request failed.
NetworkError
网络连接错误
NotNullableError<T>
A TypeError thrown by _checkNotNullable.
ParseError
数据解析错误
ResponseError
HTTP 响应错误
SmartError
SmartDio 统一错误基类(sealed class)
TimeoutError
超时错误
UnknownError
未知错误