FlexHttp class

The core HTTP client class for making network requests.

Configurable via FlexHttpBuilder, it supports common HTTP methods (GET, POST, etc.), retries, caching, streaming, and interceptors.

Constructors

FlexHttp.config({String? baseUrl})
Creates a pre-configured FlexHttp instance with a baseUrl.
factory

Properties

baseUrl String?
The base URL prepended to all request paths.
final
client HttpClient
The underlying HTTP client, lazily initialized with configuration.
no setter
defaultHeaders Map<String, String>
Default headers applied to all requests.
final
enableLogging bool
Enables logging of requests and responses.
final
hashCode int
The hash code for this object.
no setterinherited
interceptors List<FlexInterceptor>
List of interceptors for customizing requests and responses.
final
maxConnectionsPerHost int
Maximum connections per host for the underlying HTTP client.
final
maxRetries int
Maximum number of retry attempts for failed requests.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
timeout Duration
Timeout duration for requests.
final

Methods

close() → void
Closes the HTTP client and clears the cache.
delete<T>(String path, {Map<String, String>? headers, T decoder(dynamic)?}) Future<FlexResponse<T>>
Sends a DELETE request to path.
get<T>(String path, {Map<String, String>? headers, bool useCache = false, T decoder(dynamic)?}) Future<FlexResponse<T>>
Sends a GET request to path.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
patch<T>(String path, {Map<String, String>? headers, dynamic body, T decoder(dynamic)?}) Future<FlexResponse<T>>
Sends a PATCH request to path with an optional body.
post<T>(String path, {Map<String, String>? headers, dynamic body, T decoder(dynamic)?}) Future<FlexResponse<T>>
Sends a POST request to path with an optional body.
put<T>(String path, {Map<String, String>? headers, dynamic body, T decoder(dynamic)?}) Future<FlexResponse<T>>
Sends a PUT request to path with an optional body.
stream<T>(String path, {Map<String, String>? headers, T lineDecoder(String)?}) Stream<FlexStreamResponse<T>>
Streams the response from path as chunks of data.
toString() String
A string representation of this object.
inherited
upload<T>(String path, {required File file, Map<String, String>? headers, String fieldName = 'file', T decoder(dynamic)?}) Future<FlexResponse<T>>
Uploads a file to path as a multipart/form-data request.

Operators

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