Skip to main content

rxnet_plus 0.7.2 copy "rxnet_plus: ^0.7.2" to clipboard
rxnet_plus: ^0.7.2 copied to clipboard

Flexible network request framework with pluggable adapters (Dio, http, or custom), supporting various caching strategies

0.7.2 #

Breaking Changes #

  • Secure defaults - RxNetConfig.isDebug now defaults to false; debug logging must be enabled explicitly.
  • request() semantics - Returns the final cache/network/retry result. Cache-first modes now perform the network request; retries are no longer cut off by the first failure. Loop mode still returns the first result.
  • Retry filtering - By default, POST/PATCH are not retried. Use RetryPolicy.retryOnNonIdempotent to opt in; 4xx (except 408/429), cancellation and parsing errors are never retried.
  • Cache keys - Path-based cache keys are always SHA-256 hashed (32 hex chars). Existing caches become misses once.
  • Interceptor API - AdapterInterceptor methods return FutureOr<void>; async interceptors are awaited. Existing void implementations remain compatible.
  • Token refresh - TokenRefreshInterceptor now retries the original request through ErrorInterceptorHandler.retry instead of returning a synthetic response.
  • AdapterResponse.successOverride - Added so validateStatus decisions survive the adapter boundary.

Fixed #

  • RxNet.init now honors config.adapter.
  • setEnv / setDefaultEnv update the actual request base URL.
  • Network cache writes go through RxNetCache, enabling metadata and LRU/LFU/FIFO eviction.
  • Default timeouts (connect 15s / receive 30s / send 30s) and request-level timeouts.
  • URL normalization preserves // in query/fragment.
  • Download/upload now run interceptors in Dio/Http adapters.
  • DioAdapter supports dart:io File request bodies.
  • Cancel-token callbacks are removed when requests finish.
  • REQUEST_FAILED_READ_CACHE no longer emits both success and failure callbacks.
  • Binary responses are skipped by the JSON cache.

Security #

  • Log redaction covers headers, bodies, PII keys, sensitive URL query parameters and token=xxx text.
  • Certificate pinning examples no longer bypass validation.
  • Debug logging is off by default and LogUtil.e respects the debug flag.

Engineering #

  • Corrected flutter.plugin.implements placement and removed placeholder platform config.
  • Updated flutter_lints to ^5.0.0 and added a CI workflow with analyze/test/coverage.
  • Full-platform conditional imports - Web/Wasm default branches + dart.library.io for IO; rxnet_lib conditionally exports IOClient/IOHttpClientAdapter. Verified with actual Web and Windows debug builds. Added a Web compile smoke target to CI.
  • Example SDK lower bound aligned to >=3.5.0.
  • Example rebuilt - Added a responsive Material 3 Playground (all HTTP methods, query/body/header editors, cache/retry/timeout/cancel, generated code), Methods, Recipes, Logs and About pages; legacy demos remain accessible.
  • Removed generated HarmonyOS build artifacts from the repository index.
  • Fixed stale DeduplicateInterceptor / ThrottleInterceptor / ZipRequest docs.
  • ZipRequestError now implements Exception; cancellation/timeout use consistent ZipRequestError context.

Migration #

See MIGRATION_GUIDE_0.7.2.md or 迁移指南_0.7.2.md.


0.7.1 #

Fixed #

  • Web compile failure (dart2js) - Corrected a wrong conditional-import path in rxnet_log_adapter_interceptor.dart

    • 0.7.0 bug: used ../../src/adapter/implementations/http_adapter_web_stub.dart, which resolved to a non-existent src/src/... path and broke Web builds
    • Fix: use ../../adapter/implementations/http_adapter_web_stub.dart
    • Action: If you are on 0.7.0 and targeting Web, upgrade to 0.7.1 (or later)
  • HttpAdapter Web name clash - Avoid IOClient being imported from both package:http and the Web stub

    • Default client creation is now split via conditional imports (http_adapter_io.dart / http_adapter_web.dart)

Migration #

Drop-in upgrade from 0.7.0. No API changes.

dependencies:
  rxnet_plus: ^0.7.1

0.7.0 #

New Features #

  • RxNetConfig Configuration Class - Clean, type-safe configuration with Builder pattern

    • RxNetConfig replaces long parameter lists with a structured config object
    • Builder pattern: RxNetConfig.builder().baseUrl('...').cacheMode(...).build()
    • copyWith() for immutable config modifications
    • 100% backward compatible - old initNet() parameters still work
  • Cache Eviction Policies - Automatic cache size management

    • cacheMaxSize - Maximum number of cache entries (0 = unlimited)
    • CacheEvictionPolicy.lru - Least Recently Used eviction
    • CacheEvictionPolicy.lfu - Least Frequently Used eviction
    • CacheEvictionPolicy.fifo - First In First Out eviction
    • CacheMetadata tracks createdAt, lastAccessedAt, accessCount per entry
    • Automatic eviction on every cache write when size exceeds limit
  • RetryPolicy - Advanced retry strategies beyond fixed interval

    • RetryStrategy.fixed - Fixed interval (default, backward compatible)
    • RetryStrategy.exponentialBackoff - Delay doubles each attempt
    • RetryStrategy.exponentialBackoffWithJitter - Exponential + random jitter
    • maxInterval cap to prevent excessive delays
    • Factory methods: RetryPolicy.fixed(), RetryPolicy.exponentialBackoff(), RetryPolicy.exponentialBackoffWithJitter()
  • AdapterBaseOptions - Adapter-agnostic global request defaults

    • Set connectTimeout, receiveTimeout, sendTimeout globally
    • Set default headers, contentType, responseType
    • Configurable followRedirects, maxRedirects, persistentConnection
    • Applied via RxNetConfig(adapterBaseOptions: ...) or Builder
  • TokenRefreshInterceptor - Automatic token refresh on auth errors

    • Detects 401/403 responses and triggers token refresh
    • Concurrent refresh deduplication (only one refresh call at a time)
    • Customizable isUnauthorized callback
    • onRequestUpdated callback to inject new token into request
    • Lifecycle callbacks: onTokenRefreshing, onTokenRefreshed, onTokenRefreshFailed
  • DeduplicateInterceptor - Request deduplication within time window

    • Prevents duplicate requests with same path within configurable window
    • Automatically allows requests after window expires
  • ThrottleInterceptor - Request rate limiting

    • Rejects requests within throttle window after the first pass-through
    • Configurable throttle duration
  • Cache Clearing by Prefix/Pattern - Granular cache management

    • cacheManager.clearByPrefix(prefix) - Clear all entries matching prefix
    • cacheManager.clearByPattern(pattern) - Clear all entries matching regex
  • RxResult Improvements - Safer result handling

    • RxResult.success(value) factory - Guaranteed non-null value
    • requiredValue getter - Throws StateError if error or null

Improved #

  • BuildRequest Cache Integration - Cache operations now use RxNetCache directly
    • Cache reads/writes go through RxNetCache.saveNetworkCache() / readNetworkCache()
    • Eviction policies enforced automatically on cache writes

Changed #

  • Database Metadata Store - RxNetDataBase now supports metadata storage
    • putMetadata() / getMetadata() / deleteMetadata() / getAllMetadata() / cleanMetadata()
    • Separate Sembast store for cache metadata (eviction tracking)

Migration Guide #

100% backward compatible - No code changes required. New features are opt-in.

New: RxNetConfig (recommended)

Before:

await RxNet.init(
  baseUrl: "https://api.example.com",
  cacheMode: CacheMode.CACHE_EMPTY_OR_EXPIRED_THEN_REQUEST,
  cacheInvalidationTime: 60000,
  interceptors: [RxNetLogAdapterInterceptor()],
);

After:

await RxNet.init(config: RxNetConfig(
  baseUrl: "https://api.example.com",
  cacheMode: CacheMode.CACHE_EMPTY_OR_EXPIRED_THEN_REQUEST,
  cacheInvalidationTime: 60000,
  interceptors: [RxNetLogAdapterInterceptor()],
  cacheMaxSize: 500,
  cacheEvictionPolicy: CacheEvictionPolicy.lru,
  adapterBaseOptions: AdapterBaseOptions(
    connectTimeout: Duration(seconds: 10),
    receiveTimeout: Duration(seconds: 30),
  ),
));

New: RetryPolicy

Before:

RxNet.get()
  .setPath("/api/data")
  .setRetryCount(3, interval: Duration(seconds: 2))
  .request();

After:

RxNet.get()
  .setPath("/api/data")
  .setRetryPolicy(RetryPolicy.exponentialBackoff(
    maxRetries: 3,
    baseInterval: Duration(seconds: 1),
    maxInterval: Duration(seconds: 10),
  ))
  .request();

0.6.2 #

Fixed #

  • ZipRequest Code Quality - Improved implementation and maintainability

Changed #

  • ZipRequest API Simplification - Breaking change with clear migration path

0.6.1 #

New Features #

  • Concurrent Callback Requests - Execute multiple callback-based requests in parallel
  • Sembast Database - Replaced Hive with pure Dart database solution

Fixed #

  • Breakpoint Download Fixes - Works correctly with all adapters
  • HttpAdapter Improvements - Multipart upload, stream responses, progress tracking
  • URL Path Normalization - Fixed multiple slashes in request URLs
  • Web Platform Support - Fixed adapters on Web platform

0.6.0 #

Added #

  • Pluggable Adapter Architecture - DioAdapter, HttpAdapter, MockAdapter
  • Unified Interceptor System - Adapter-agnostic AdapterInterceptor interface
  • Custom Adapter Support - Implement NetworkAdapter interface

0.5.0 #

  • Parameter type separation - Path, query, and body parameters
  • RESTful automatic detection - No manual settings required
  • API semantic improvement - More intuitive method names
  • Low-level reconstruction - Updated BuildRequest

0.4.x #

  • Generic request support with type conversion
  • RESTFul @path style request support
  • Overall architecture redesign
1
likes
130
points
755
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Flexible network request framework with pluggable adapters (Dio, http, or custom), supporting various caching strategies

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

crypto, dio, flutter, http, path, path_provider, path_provider_platform_interface, sembast, sembast_web, web

More

Packages that depend on rxnet_plus

Packages that implement rxnet_plus