app_smart_network 1.0.2 copy "app_smart_network: ^1.0.2" to clipboard
app_smart_network: ^1.0.2 copied to clipboard

A smart Flutter network package with built-in error handling, retry logic, and multilingual error messages (en/ar).

1.0.2 #

Bug fixes #

  • ErrorHandler.handleError now passes an ApiException through unchanged instead of re-wrapping it as a generic 'UnexpectedError' (status 0). This prevented the real error type, status code, and message from reaching callers whenever an ApiException entered the catch block (e.g. thrown by a custom interceptor).
  • RequestService.executeensureConnected(), withMobileTimeouts(), and resolveUrl() are now inside the single try/catch block, so every error type (connectivity, timeout, bad response, certificate, cancel) flows through ErrorHandler via one consistent code path.

1.0.1 #

Bug fixes #

  • ApiService.instance now throws a StateError instead of silently creating a broken client when initialize() has not been called yet.
  • ApiService.isInitialized getter added — use it to safely check whether initialize() has been called before accessing instance.
  • withMobileTimeouts no longer discards user-supplied Options fields. It now mutates the existing object in-place, only setting receiveTimeout when the caller has not already provided one.
  • removeAppLocale() now restores the locale that was active at initialize() time (from NetworkConfig.defaultHeaders['Accept-Language']) instead of always falling back to 'en'.
  • NetworkLocale.clearCustomTranslations([locale]) added — removes custom translations for a specific locale, or for all locales when called without an argument.

1.0.0 #

Initial stable release.

Features #

  • ApiService singleton with initialize(NetworkConfig) entry point
  • NetworkConfig — configure base URL, timeouts, default headers, SSL, and unauthorized callback
  • HttpMethod enum — get, post, put, patch, delete
  • RequestService — unified HTTP request execution with connectivity guard and mobile timeout extension
  • DownloadRequestService — file download with progress callback
  • UploadRequestService — multipart file upload with extra fields and progress callback
  • NetworkLocale — locale-aware error messages; built-in English and Arabic translations covering all standard HTTP status codes and network error types; extensible via addTranslations()
  • setAppLocale(locale) — sets Accept-Language header and switches error-message locale in one call
  • ErrorHandler — converts DioException to ApiException with translated messages
  • ApiException — rich exception with statusCode, apiErrorCode, errorCategory, hasApiErrorCode(), and getResponseField()
  • ServerFailure / CacheFailure — domain-layer Failure wrappers (Equatable)
  • Automatic retry on idempotent methods (GET, PUT, DELETE) with exponential back-off (3 retries: 1 s, 2 s, 3 s)
  • Connectivity check before every request with a single 600 ms retry for transient states
  • Background JSON decoding via compute isolate
  • Debug request/response logging via PrettyDioLogger (debug builds only)
  • Per-request baseUrl override, cancel token, query parameters, and send/receive progress callbacks
  • example/ app demonstrating all features against JSONPlaceholder API
1
likes
0
points
528
downloads

Publisher

unverified uploader

Weekly Downloads

A smart Flutter network package with built-in error handling, retry logic, and multilingual error messages (en/ar).

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

connectivity_plus, dio, dio_smart_retry, equatable, flutter, pretty_dio_logger

More

Packages that depend on app_smart_network