s_client 3.0.0
s_client: ^3.0.0 copied to clipboard
Safe-by-default HTTP client with dual backend support (http/dio), never throws exceptions, returns result tuples, supports interceptors, retry logic, and type-safe JSON parsing.
3.0.0 #
s_packagesdependency upgraded to ^3.0.0
2.2.2 #
s_packagesdependency upgraded to ^1.5.3s_clientsub-package improvements:- Added
autoRedirectStatusCodesparameter toput(),putJson(), and_performPut()— enables manual redirect handling for PUT, POST requests, automatically following theLocationheader with a GET request when the response status code matches (consistent with existing POST redirect behavior) - Fixed
maxRedirectsguard in_performPut()— now only set whenfollowRedirectsis enabled (matching POST behavior) - Stripped Dio
BaseOptionsdown to onlybaseUrlandvalidateStatus— all other configuration (connectTimeout,receiveTimeout,sendTimeout,headers,followRedirects,maxRedirects) is now applied per-request viadio.Options, avoiding web-specific XHR issues (e.g.connectTimeoutsettingxhr.timeout, defaultContent-Typetriggering CORS preflights) connectTimeoutandsendTimeoutare now forwarded to every_perform*method (GET, POST, PUT, PATCH, DELETE, HEAD, download, downloadToFile, uploadFile) — previously onlyreceiveTimeoutwas passed through- Explicitly forwarded
Content-Typefrom request headers todio.Options.contentTypein POST, PUT, and PATCH — ensures Dio's request transformer uses the correct encoder (e.g. form-urlencoded vs JSON) regardless ofBaseOptionsdefaults - Changed
ClientConfig.connectTimeout,receiveTimeout, andsendTimeoutdefaults fromDuration(seconds: 30)tonull(no timeout) - Added
_withTimeout<T>()helper — applies.timeout()only when the duration is non-null, replacing all inline.timeout()calls onhttppackage requests - Applied
maxRedirectsguard (config.followRedirects ? config.maxRedirects : null) consistently to PATCH, DELETE, HEAD, download, downloadToFile, and uploadFile — these methods were previously passingconfig.maxRedirectsunconditionally
- Added
2.2.1 #
- Fixed
Dioredirect option handling by only settingmaxRedirectswhenfollowRedirectsis enabled - Applied this fix consistently to base
Dio optionsand per-requestDiooptions inGETandPOSTflows
2.2.0 #
- Added
validateStatusparameter (bool Function(int?)?) to all HTTP methods (get,getJson,getJsonList,post,postJson,put,putJson,patch,patchJson,delete,deleteJson,head,download,downloadToFile,uploadFile) — allows per-request control over which status codes are treated as valid - Fixed Dio request options:
followRedirects,maxRedirects, andvalidateStatusare now correctly forwarded to all_perform*methods — previously onlyreceiveTimeoutandheaderswere passed through - flutter/Dart SDKs updated
2.1.1 #
s_packagespackage dependency upgraded
2.1.0 #
s_packagesdependency upgraded to ^1.3.0- Added
putJson<T>()typed variant for PUT requests with JSON deserialization - Added
patchJson<T>()typed variant for PATCH requests with JSON deserialization - Added
deleteJson<T>()typed variant for DELETE requests with JSON deserialization
2.0.0 #
- package no longer holds the source code for it, but exports/exposes the
s_packagespackage instead, which will hold this package's latest source code. - The only future changes to this package will be made via
s_packagespackage dependency upgrades, in order to bring the new fixes or changes to this package - dependent on
s_packages: ^1.1.2
1.1.0 #
- dio package dependency upgraded from 5.4.0 to 5.9.0 --> FileAccessMode feature added to downloadToFile, now supporting directly writing to disk and supports resume capabilities.
- README updated
1.0.0 #
- Initial release
- Safe by Default: All requests wrapped in internal try-catch blocks
- Never throws unhandled exceptions - guaranteed safe execution
- All errors captured and returned as
ClientExceptionin tuple - No need for manual try-catch blocks around HTTP requests
- Unified API: All HTTP methods return result tuples AND support optional callbacks
- Every method returns
(ClientResponse?, ClientException?)tuple for structured error handling - Optional callbacks (
onSuccess,onError,onHttpError,onStatus,onProgress) for reactive programming - Use tuple-only, callbacks-only, or BOTH approaches simultaneously
- Callbacks and tuple results receive the same response object
- Every method returns
- Dual backend support (http and dio packages)
- Switch between lightweight
httpor feature-richdioat runtime - Identical API regardless of backend
- Switch between lightweight
- Type-safe JSON parsing
getJson<T>,getJsonList<T>,postJson<T>with automatic deserialization- Custom
fromJsonfunctions for type safety
- Customizable success and error status codes
- Define which HTTP status codes are success vs error
- Per-request or global configuration
- Built-in interceptors:
LoggingInterceptor: Request/response logging with pretty-print JSONAuthInterceptor: Bearer, API Key, Basic, Custom authenticationCacheInterceptor: In-memory response cachingClientInterceptor: Base class for custom interceptors
- Automatic retry logic with exponential backoff
- Configurable retry attempts, delays, and status codes
- Per-request cancellation support
- File operations
- Upload files with progress callbacks
- Download files with progress callbacks
- Request cancellation
- Cancel individual requests by key
- Cancel all pending requests
- Comprehensive test coverage
- Clean, modern Dart 3+ API with records (tuples), sealed classes, and pattern matching