api_network_kit 1.2.0
api_network_kit: ^1.2.0 copied to clipboard
A batteries-included, no-codegen Dio wrapper for Flutter/Dart featuring typed parsing, resilient retry, automatic token refresh, caching, pagination, and WASM-ready checks.
1.2.0 #
- New PATCH request helper: Added
patch<T>()method supporting typed JSON response parsing, mirroringput<T>(). - Multiple file upload: Added
uploadFiles<T>()to allow uploading multiple files under the same multipart field name. - Improved Caching: Added stable cache keys with parameter normalization/sorting to avoid duplicate cache entries for the same query values in different orders.
- Fail-Fast Validations: Added configuration validation checks for timeouts, retry base, and max-retry parameters to fail-fast if invalid values are passed to
BaseApiClient. - Capped Exponential Backoff: Capped exponential retry delay base with a maximum of 30 seconds and introduced deterministic jitter to avoid thundering herd issues.
- Refactored Requests: Consolidated common network mechanics into unified internal request handlers to eliminate duplicate code and optimize code maintainability.
1.1.2 #
- WASM Compatibility Fix: Replaced the external
package:loggerdependency with a custom, fully WASM-compatible console logger (ApiLogger) built directly into the package. This removes thedart:iodependency transitively introduced by the logger, resolving the WASM/Web compatibility issue. - cURL Request Logging: Implemented a cURL command generator in
ApiInterceptorthat prints a developer-friendly, ready-to-runcURLcommand for every HTTP request. - Updated Environment Constraints: Updated environment targets in
pubspec.yamlto Dart>=3.4.0 <4.0.0and Flutter>=3.22.0to comply with modern WASM compilation pipelines.
1.1.1 #
- Shortened package description in
pubspec.yamlto comply with pub.dev package guidelines. - Wrapped generic type references in backticks in doc comments to resolve HTML parsing warnings during static analysis.
1.1.0 #
Breaking changes (non-API) #
- Moved
connectivity_plusandflutter_blocfrom hard dependencies todev_dependencies. The library no longer forces Flutter or native plugins on pure-Dart / Web / WASM consumers. - Moved the clean-architecture auth example from
lib/features/auth/intoexample/auth_feature/. It was never part of the published library API.
New features #
- Automatic token refresh & retry (Priority 2): Added a
TokenRefresherstrategy andTokenRefreshInterceptor. On a 401, the interceptor calls the refresher, updates the stored token, and retries the original request once. Infinite loops are prevented via a per-request flag. - Configurable pagination (Priority 3): Added
PaginationStrategy,PaginationConfig,OffsetPaginationStrategy, andCursorPaginationStrategy.getPaginatednow accepts an optionalpaginationConfig/paginationStrategy. Defaults preserve the legacy hardcoded shape. - Cache abstraction & request deduplication (Priority 4): Added a
CacheStoreinterface;ApiCachenow implements it with ETag storage. AddedRequestDeduplicatorso concurrent identical GETs share a single in-flight request. ETag headers are now captured from responses. - Web/WASM-ready connectivity (Priority 5): Added a
ConnectivityCheckerinterface with aNoOpConnectivityCheckerdefault, so the package runs on pure-Dart and Web/WASM without native plugins. Flutter consumers can inject aconnectivity_plus-backed checker. - Injectable logger (Priority 6):
ApiLoggeris now instance-based and injectable, with a static facade for backward compatibility.
Bug fixes #
- Fixed broken String parser path (Priority 1):
parseResponsenow JSON-decodesStringbodies withjsonDecodeinstead of casting aStringtoMap(which always threw). - Preserved error response bodies (Priority 1): All exceptions now carry
statusCode,data, anderrorspopulated fromerror.response?.data, making 422 field-validation errors reachable. - Fixed
clearInterceptors()(Priority 6): It now preserves the internal auth and token-refresh interceptors instead of removing them and silently breaking auth. - Added exhaustive handling of
DioExceptionType.transformTimeout,connectionError, andbadCertificateinmapDioError.
Tests #
- Added a real test suite using
http_mock_adapter: response parsing, error mapping per status code (incl. 422 body preservation), cache hit/miss/expiry, token injection,clearInterceptorsauth preservation, connectivity checks, pagination strategies, and request deduplication.
Packaging #
- Added
topics: [http, network, api-client, dio, rest]for pub.dev discoverability. - Bumped version to
1.1.0.
1.0.3 #
- Fixed Example tab detection on pub.dev by adding
example/README.md. - Rewrote root
README.mdto properly document the package.
1.0.2 #
- Updated repository link to point to the correct GitHub repository.
1.0.1 #
- Upgraded dependencies to latest compatible versions.
- Fixed all remaining code lints and static analysis warnings for maximum score.
1.0.0 #
- Initial release of
api_network_kit. - Scalable Flutter package featuring a reusable API client (api_kit) for robust HTTP handling using Dio.
- Robust error handling, retry mechanism, connectivity checks, logging, and response caching.