SturdyHttp class

A client that facilitates network interactions. This client offers the following benefits:

  • Type-safe responses: Allowing the consumer to provide parsing functions, the client is able to hand back strongly-typed response models for direct consumption.
  • Exhaustive response handling: The client does not rely on Exceptions for signaling errors, but instead utilizes the NetworkResponse type to enumerate the various possible responses, both successful and unsuccessful. Only in truly unexpected cases are Exceptions re-thrown.
  • Event-based subscription: The client emits events for things that consumers may be interested in to the provided SturdyHttpEventListener. This is useful for things like auth failures, or response decoding errors.

Constructors

SturdyHttp({required String baseUrl, Deserializer deserializer = const MainIsolateDeserializer(), List<Interceptor> interceptors = const [], SturdyHttpEventListener? eventListener, HttpClientAdapter? customAdapter, Map<String, String>? proxy, bool inferContentType = true, RetryBehavior retryBehavior = const NeverRetry()})
A client that facilitates network interactions. This client offers the following benefits:

Properties

baseUrl String
The base URL of the underlying Dio instance.
no setter
hashCode int
The hash code for this object.
no setterinherited
httpClientAdapter → HttpClientAdapter
The HttpClientAdapter provided when this SturdyHttp was constructed.
no setter
interceptors UnmodifiableListView<Interceptor>
The interceptors provided when this SturdyHttp was constructed.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

execute<R, M>(NetworkRequest request, {required M onResponse(NetworkResponse<R> response)}) Future<M>
Executes the provided request and returns the result of type M that is produced by the onResponse parameter.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited
withBaseUrl(String baseUrl) SturdyHttp
A client that facilitates network interactions. This client offers the following benefits:

Operators

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