sturdy_http library

Classes

AuthFailure
Indicates that a network request returned a response with status code 401.
BackgroundDeserializer
A Deserializer that shifts its work to a worker isolate named _workerIsolateName. The worker isolate is spawned on the first request to deserialize for this instance and re-used to avoid the high cost of spinning up new Isolates.
DecodingError
Indicates that there was an Exception thrown when attempting to decode the server response.
DeleteRequest
A NetworkRequest with NetworkRequestType.Delete.
Deserializer
Contract to be implemented to facilitate transforming NetworkResponse into the desired application domain models.
EmptyRequestBody
An empty body. Results in null being passed to data of the request.
Forbidden<R>
403 - for responses when the request was authenticated but the action is not authorized/allowed.
GenericError<R>
Any "other" error not covered by the above cases. If a DioException is present, it has an error status we don't handle. Often this error will occur when no response was received from the server.
GetRequest
A NetworkRequest with NetworkRequestType.Get.
JsonRequestBody
A JSON body. Passed directly to data of the request. If inferContentType has been provided as true to the SturdyHttp instance, will result in an application-json content-type.
MainIsolateDeserializer
A Deserializer that does its work directly on the main isolate.
NetworkRequest
The base class representing a request to be executed by SturdyHttp.
NetworkRequestBody
The body of a NetworkRequest. Note that this type is aimed at providing readability and type safety and does not dictate behavior of SturdyHttp with regards to the content-type header. If you want SturdyHttp to infer the content-type header, configure this via the inferContentType parameter when constructing the instance.
NetworkResponse<R>
The produced object after SturdyHttp processes a NetworkRequest.
NetworkResponseFailure<R>
NetworkResponseSuccess<R>
NeverRetry
Indicates that a request should never be retried.
NotFound<R>
404 - for responses when we could not locate a resource, or when someone would attempt to access a forbidden resource due to a bug.
OkNoContent<R>
OkResponse<T>
PostRequest
A NetworkRequest with NetworkRequestType.Post.
PutRequest
A NetworkRequest with NetworkRequestType.Put.
RawRequest
A NetworkRequest that allows for passing a NetworkRequestType (useful for when this can't be known until runtime). It also defaults to a raw (null) body.
RawRequestBody
A raw body. Allows for nullable untyped data that is passed directly to data of the request, useful for instances where the data type is not known until runtime. If inferContentType has been provided as true to the SturdyHttp instance and the data can be used to infer the content-type header, it will be inferred.
RequestCompleted
Indicates that a network request has completed and a response was received. This event fires for all requests that receive any HTTP response, regardless of success or error status.
Retry
Indicates that a request should be retried up to maxRetries times with a delay of retryInterval between each attempt. Optionally, a RetryClause can be provided to further customize the retry behavior.
RetryBehavior
Specifies how a failed network request should be handled as it relates to retrying the request.
ServerError<R>
500 - for responses where the service had an error while processing the request.
ServiceUnavailable<R>
503 - for responses when an underlying service issue prevents us from fulfilling the request.
SturdyHttp
A client that facilitates network interactions. This client offers the following benefits:
SturdyHttpEvent
Represents an event that occurs during a request lifecycle.
SturdyHttpEventListener
A listener that can optionally be supplied when constructing an SturdyHttp to be notified when various events occur while processing NetworkRequests.
Unauthorized<R>
401 - for responses when the request was missing required authentication.
UnprocessableEntity<R>
422 - for responses when the request inputs failed our validations.
Unspecified
Indicates that the behavior for retrying a request is unspecified.
UpgradeRequired<R>
426 - for responses when a client version upgrade is required

Enums

NetworkRequestType
A type representing the available HTTP request methods.

Extensions

DioExceptionX on DioException
NetworkResponseX on NetworkResponse<R>
Extensions on the NetworkResponse type
RetryBehaviorX on RetryBehavior
Extensions on the RetryBehavior type.

Constants

defaultRetryStatusCodes → const List<int>
The default status codes that will trigger a retry.

Functions

defaultRetryClause(Response<Object?>? r) bool
The default RetryClause to be used when Retry is specified without a custom RetryClause.

Typedefs

Json = Map<String, dynamic>
A nicety to represent a Map as json while making network requests
RetryClause = bool Function(Response<Object?>? r)
A function that returns true if the given Response r should be retried.