api_network_kit 1.1.0
api_network_kit: ^1.1.0 copied to clipboard
A batteries-included, no-codegen Dio wrapper for Flutter and Dart — typed parsing, resilient retry, automatic token refresh, persistent/ETag-aware caching, pluggable pagination, and Web/WASM-ready con [...]
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.