s_client/s_client library

s_client package - Modern HTTP Client

A powerful HTTP client package supporting both http and dio backends with advanced features like interceptors, caching, retry, and more.

Classes

AuthInterceptor
An interceptor that adds authentication headers to requests.
CacheInterceptor
An interceptor that provides simple in-memory caching for GET requests.
ClientConfig
Configuration class for Client.
ClientInterceptor
Base class for interceptors that can modify requests and responses.
ClientRequest
A request object that can be modified by interceptors.
ClientResponse
A unified response class that works with both http and dio backends.
LoggingInterceptor
An interceptor that logs HTTP requests and responses.
SClient
A powerful HTTP client supporting both http and dio backends.

Enums

AuthType
Type of authentication to use.
ClientErrorType
Types of errors that can occur during HTTP requests.
ClientType
Enum to specify which client backend to use.
FileAccessMode
The file access mode when downloading a file, corresponds to a subset of dart:io::FileMode.

Constants

defaultErrorCodes → const Set<int>
Default error status codes (4xx and 5xx).
defaultJsonHeaders → const Map<String, String>
Default headers for JSON requests.
defaultSuccessCodes → const Set<int>
Default success status codes (2xx).

Typedefs

ClientResult = (ClientResponse?, ClientException?)
A result type for HTTP requests containing either a response or an error.
JsonResult<T> = (T?, Object?)
A result type for parsed JSON responses.
OnError = void Function(ClientException error)
Callback for error responses.
OnHttpError = void Function(int statusCode, ClientResponse response)
Callback for HTTP error responses (non-2xx that aren't exceptions).
OnProgress = void Function(int current, int total)
Callback for download/upload progress.
OnStatus = void Function(int statusCode, ClientResponse response)
Callback for custom status code handling.
OnSuccess = void Function(ClientResponse response)
Callback for successful responses.
OnSuccessTyped<T> = void Function(T data, ClientResponse response)
Callback for successful responses with typed data.

Exceptions / Errors

ClientException
A unified exception class that works with both http and dio backends.