NetworkingClient class

Base networking client for communicating with external HTTP Web APIs. Internally uses Dart http client library and requires one instance of it to start the client. This is done to allow mocking of networking requests.

Strives to be a functional networking client, removing side effects without throwing errors. Instead it encapsulates them in a Failure monad.

Also requires the injection of the base URL which requests are originated.

Permits the timeout of a request after a defined duration. The default timeout duration is 5 minutes.

Implementers

Constructors

NetworkingClient({required Uri baseUrl, required Client httpClient, Duration timeoutDuration = kDefaultTimeoutDuration, List<Interceptor> interceptors = kDefaultInterceptors})
const

Properties

baseUrl Uri
final
hashCode int
The hash code for this object.
no setterinherited
httpClient → Client
final
interceptors List<Interceptor>
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
timeoutDuration Duration
final

Methods

delete({required String endpoint, Map<String, String>? headers, Map<String, String>? queryParameters}) Future<Either<RequestError, Response>>
get({required String endpoint, Map<String, String>? headers, Map<String, String>? queryParameters}) Future<Either<RequestError, Response>>
multipart({required String endpoint, Map<String, String>? form, Map<String, Uint8List>? files, Map<String, String>? headers, Map<String, String>? queryParameters}) Future<Either<RequestError, Response>>
Crafts and sends a multipart/form-data request.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
patch({required String endpoint, ContentType contentType = ContentType.json, String? data, Map<String, String>? headers, Map<String, String>? queryParameters}) Future<Either<RequestError, Response>>
post({required String endpoint, ContentType contentType = ContentType.json, String? data, Map<String, String>? headers, Map<String, String>? queryParameters}) Future<Either<RequestError, Response>>
put({required String endpoint, ContentType contentType = ContentType.json, String? data, Map<String, String>? headers, Map<String, String>? queryParameters}) Future<Either<RequestError, Response>>
send({required Request request}) Future<Either<RequestError, Response>>
toString() String
A string representation of this object.
inherited

Operators

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