playx_network library

Classes

BackgroundTransformer
The default Transformer for Dio.
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.
CancelToken
Controls cancellation of Dio's requests.
DefaultApiError
Default api error model that can be received from network response. can be updated based on the response.
DefaultEnglishExceptionMessage
Default client error messages. To customize your messages you can override ExceptionMessage the same way as this class and customize the messages.
DefaultRetryEvaluator
Dio
Dio enables you to make HTTP requests easily.
DioClient
A client for making network requests using Dio.
DioEventProcessor
This is an EventProcessor, which improves crash reports of DioErrors. It adds information about DioError.requestOptions if present and also about the inner exceptions.
DioForNative
Implements features for Dio on native platforms.
DioMixin
ErrorInterceptorHandler
The handler for interceptors to handle error occurred during the request.
ExceptionMessage
Class that can be extended to implement your own custom errors message.
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
Headers
The headers class for requests and responses.
HttpClientAdapter
HttpAdapter is a bridge between Dio and HttpClient.
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.
IOHttpClientAdapter
The default HttpClientAdapter for native platforms.
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
An upload content that is a part of MultipartRequest. This doesn't need to correspond to a physical file.
NetworkError<T>
Generic Wrapper class that represents a failed network response.
NetworkResult<T>
Generic Wrapper class for handling network results.
NetworkSuccess<T>
Generic Wrapper class that represents a successful network response.
Options
The configuration for a single request. BaseOptions and Options will be merged into one RequestOptions before sending the requests. See Options.compose.
PlayxNetworkClient
PlayxNetworkClient is a Wrapper around Dio that can perform api request With better error handling and easily get the result of any api request.
PlayxNetworkClientSettings
This class contains the settings for the PlayxNetworkClient. You can customize the settings based on your needs.
PlayxNetworkLoggerSettings
Logger settings used to customize what should be logged by the application when performing a request.
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.
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.
RetryInterceptor
An interceptor that will try to send failed request again
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.
Transformer
Transformer allows changes to the request/response data before it is sent/received to/from the server.

Enums

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.

Mixins

OptionsMixin
The mixin class for options that provides common attributes.

Extensions

DioClientExtensions on Dio
OptionsX on Options
RequestOptionsX on RequestOptions
SentryDioExtension on Dio
Extension to add performance tracing for Dio

Constants

defaultRetryableStatuses → const Set<int>
retryableStatuses → const Set<int>
status100Continue → const int
status101SwitchingProtocols → const int
status102Processing → const int
status200OK → const int
status201Created → const int
status202Accepted → const int
status203NonAuthoritative → const int
status204NoContent → const int
status205ResetContent → const int
status206PartialContent → const int
status207Multistatus → const int
status208AlreadyReported → const int
status226IMUsed → const int
status300MultipleChoices → const int
status301MovedPermanently → const int
status302Found → const int
status303SeeOther → const int
status304NotModified → const int
status305UseProxy → const int
status306SwitchProxy → const int
status307TemporaryRedirect → const int
status308PermanentRedirect → const int
status400BadRequest → const int
status401Unauthorized → const int
status402PaymentRequired → const int
status403Forbidden → const int
status404NotFound → const int
status405MethodNotAllowed → const int
status406NotAcceptable → const int
status407ProxyAuthenticationRequired → const int
status408RequestTimeout → const int
status409Conflict → const int
status410Gone → const int
status411LengthRequired → const int
status412PreconditionFailed → const int
status413PayloadTooLarge → const int
status413RequestEntityTooLarge → const int
status414RequestUriTooLong → const int
status414UriTooLong → const int
status415UnsupportedMediaType → const int
status416RangeNotSatisfiable → const int
status416RequestedRangeNotSatisfiable → const int
status417ExpectationFailed → const int
status418ImATeapot → const int
status419AuthenticationTimeout → const int
status421MisdirectedRequest → const int
status422UnprocessableEntity → const int
status423Locked → const int
status424FailedDependency → const int
status426UpgradeRequired → const int
status428PreconditionRequired → const int
status429TooManyRequests → const int
status431RequestHeaderFieldsTooLarge → const int
status440LoginTimeout → const int
From IIS
status451UnavailableForLegalReasons → const int
status460ClientClosedRequest → const int
From AWS Elastic Load Balancer
status499ClientClosedRequest → const int
From ngnix
status500InternalServerError → const int
status501NotImplemented → const int
status502BadGateway → const int
status503ServiceUnavailable → const int
status504GatewayTimeout → const int
status505HttpVersionNotSupported → const int
status506VariantAlsoNegotiates → const int
status507InsufficientStorage → const int
status508LoopDetected → const int
status510NotExtended → const int
status511NetworkAuthenticationRequired → const int
status520WebServerReturnedUnknownError → const int
status521WebServerIsDown → const int
status522ConnectionTimedOut → const int
status523OriginIsUnreachable → const int
status524TimeoutOccurred → const int
status525SSLHandshakeFailed → const int
status526InvalidSSLCertificate → const int
status527RailgunError → const int
status598NetworkReadTimeoutError → const int
status599NetworkConnectTimeoutError → const int

Functions

defaultDioExceptionReadableStringBuilder(DioException e) String
The default implementation of building a readable string of DioException.
isRetryable(int statusCode) bool
Be careful: this method do not take into account RetryInterceptor.retryableExtraStatuses

Typedefs

CreateHttpClient = HttpClient Function()
The signature of IOHttpClientAdapter.createHttpClient. Can be used to provide a custom HttpClient for Dio.
DefaultHttpClientAdapter = IOHttpClientAdapter
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.
ErrorMapper = String? Function(dynamic json)
Function that converts json error response from api to error message.
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.
JsonMapper<T> = FutureOr<T> Function(dynamic json)
Function that converts json response to the required model.
OnHttpClientCreate = HttpClient? Function(HttpClient client)
The signature of IOHttpClientAdapter.onHttpClientCreate.
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.
RetryEvaluator = FutureOr<bool> Function(DioException error, int attempt)
UnauthorizedRequestHandler = void Function(Response? response)
Function that handles unauthorized request.
ValidateCertificate = bool Function(X509Certificate? certificate, String host, int port)
The signature of IOHttpClientAdapter.validateCertificate.
ValidateStatus = bool Function(int? status)
The type of a response status code validate callback.

Exceptions / Errors

ApiException
Exception for API-related errors.
ConflictException
Exception for conflicts (409).
DefaultApiException
Default API exception (for unhandled errors).
DioException
DioException describes the exception info when a request failed.
EmptyResponseException
Exception for empty responses (204).
InternalServerErrorException
Exception for internal server errors (500).
InvalidFormatException
Exception for invalid response format.
NetworkException
Base class for handling API errors and providing suitable error messages.
NoInternetConnectionException
Exception for no internet connection.
NotFoundException
Exception for "Not Found" errors (404).
NotNullableError<T>
A TypeError thrown by _checkNotNullable.
RequestCanceledException
Exception for request cancellation.
RequestTimeoutException
Exception for request timeout (408).
SendTimeoutException
Exception for request send timeout.
ServiceUnavailableException
Exception for service unavailable (503).
UnableToProcessException
Exception for unprocessable entity (422).
UnauthorizedRequestException
Exception for unauthorized requests (401, 403).
UnexpectedErrorException
Exception for unexpected errors.