Client class abstract

A stateless HTTP client with configurable global settings.

Supports GET, POST, PUT, PATCH, DELETE, file upload/download, request interceptors, and post-response hooks.

Constructors

Client()

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

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

Static Properties

baseUrl String
Base URL for all requests.
getter/setter pair
defaultHeaders Map<String, String>
Default headers applied to every request.
getter/setter pair
globalAfterEffect AfterEffect?
Optional global after-response effect.
getter/setter pair
globalInterceptor Interceptor?
Optional global request interceptor.
getter/setter pair
useGlobalAfterEffect bool
Whether to automatically invoke globalAfterEffect after each response.
getter/setter pair
useGlobalInterceptor bool
Whether to automatically invoke globalInterceptor before each request.
getter/setter pair

Static Methods

configure({String? base, Map<String, String>? headers, Interceptor? interceptor, AfterEffect? afterEffect, bool? applyGlobalInterceptor, bool? applyGlobalAfterEffect}) → void
Configures the HTTP client globally.
delete(String path, {Map<String, String>? headers, dynamic body, OnSuccess? onSuccess, OnError? onError, Interceptor? interceptor, AfterEffect? afterEffect}) Future<String>
Sends an HTTP DELETE request to path with optional body.
downloadFile(String path, String saveToPath, {Map<String, String>? headers, OnSuccess? onSuccess, OnError? onError}) Future<String>
Downloads content from path and saves it to saveToPath.
get(String path, {Map<String, String>? headers, OnSuccess? onSuccess, OnError? onError, Interceptor? interceptor, AfterEffect? afterEffect}) Future<String>
Sends an HTTP GET request to path.
patch(String path, {Map<String, String>? headers, dynamic body, OnSuccess? onSuccess, OnError? onError, Interceptor? interceptor, AfterEffect? afterEffect}) Future<String>
Sends an HTTP PATCH request to path with optional body.
post(String path, {Map<String, String>? headers, dynamic body, OnSuccess? onSuccess, OnError? onError, Interceptor? interceptor, AfterEffect? afterEffect}) Future<String>
Sends an HTTP POST request to path with optional body.
put(String path, {Map<String, String>? headers, dynamic body, OnSuccess? onSuccess, OnError? onError, Interceptor? interceptor, AfterEffect? afterEffect}) Future<String>
Sends an HTTP PUT request to path with optional body.
uploadFile(String path, File file, {Map<String, String>? headers, String fieldName = 'file', OnSuccess? onSuccess, OnError? onError}) Future<String>
Uploads a file via multipart POST to path.