netguard library
A Dio-based HTTP client with caching, connectivity handling, authentication, retries, deduplication and certificate pinning.
Classes
- AdvanceAuthCallbacks
- Ready-made AuthCallbacks that holds tokens in memory and delegates refresh and logout to closures you supply.
- AuthCallbacks
- Hooks NetGuard calls to read, refresh and discard credentials.
- AuthConfig
- Configuration for AuthInterceptor.
- AuthInterceptor
- Attaches credentials to requests and recovers from rejected tokens.
- AuthManager
- Owns a client's authentication state.
- BaseOptions
-
A set of base settings for each
Dio(). BaseOptions and Options will be merged into one RequestOptions before sending the requests. See Options.compose. - CacheEntry
- A stored cache entry.
- CacheManager
- Static facade over ResponseCache.shared.
- CacheStore
- Platform-specific key/value backing store for the response cache.
- CancellationRegistry
- Groups CancelTokens under a caller-defined tag so a whole screen's worth of requests can be cancelled in one call.
- CancelToken
- Controls cancellation of Dio's requests.
- CertificatePinning
- Rejects TLS connections whose server certificate is not one you expect.
- ConnectivityProbe
- Verifies that a reported network connection can actually reach a server.
- Dio
- Dio enables you to make HTTP requests easily.
- FormData
- A class to create readable "multipart/form-data" streams. It can be used to submit forms and file uploads to http server.
- Headers
- The headers class for requests and responses.
- HttpClientAdapter
-
HttpAdapteris a bridge between Dio and HttpClient. - Interceptor
- Interceptor helps to deal with RequestOptions, Response, and DioException during the lifecycle of a request before it reaches users.
- Interceptors
- A Queue-Model list for Interceptors.
- InterceptorsWrapper
- A helper class to create interceptors in ease.
- Jwt
- Minimal, allocation-light reader for JWT claims.
- MetricsSnapshot
- Rolling aggregate of RequestMetrics, useful for a debug overlay.
- MultipartFile
-
An upload content that is a part of
MultipartRequest. This doesn't need to correspond to a physical file. - NetGuard
- A Dio-based HTTP client with caching, connectivity handling, authentication, retries and certificate pinning.
- NetGuardBase
- Shared request machinery for NetGuard.
- NetGuardInterceptors
- NetGuard interceptors wrapper around Dio's Interceptors
- NetGuardLogger
- Configurable logger used across NetGuard.
- NetGuardLogInterceptor
- Human-readable request/response logging with credential redaction.
- NetGuardLogRecord
- A single log record produced by NetGuard.
- NetGuardOptions
- Configuration for a NetGuard client.
- NetworkInterceptor
- Gates outbound requests on connectivity.
- NetworkService
- Tracks device connectivity and publishes changes as a broadcast stream.
- OfflineQueue
- Durable store of requests awaiting connectivity.
- Options
- The configuration for a single request. BaseOptions and Options will be merged into one RequestOptions before sending the requests. See Options.compose.
- QueuedInterceptor
- Interceptor in queue.
- QueuedInterceptorsWrapper
- A helper class to create QueuedInterceptor in ease.
- QueuedRequest
- A request persisted for replay after connectivity returns.
- QueueReplayResult
- Outcome of replaying one queued request.
- RateLimiter
- Bounds how many requests NetGuard has in flight at once, and optionally how fast new ones may start.
- RefreshResult
- Outcome of a refresh attempt, cached for AuthConfig.refreshTokenCooldown.
- RequestMetrics
- Timing and outcome information for a single logical request.
- RequestOptions
- The internal request option class that is the eventual result after BaseOptions and Options are composed.
-
Response<
T> - The Response class contains the payload (could be transformed) that respond from the request, and other information of the response.
- ResponseCache
- Platform-independent response cache.
- RetryPolicy
- Controls how failed requests are retried.
- Transformer
- Transformer allows changes to the request/response data before it is sent/received to/from the server.
Enums
- CachePolicy
- How a request should interact with the response cache.
- DioExceptionType
- The exception enumeration indicates what type of exception has happened during requests.
- ListFormat
- Specifies the array format (a single parameter with multiple parameter or multiple parameters with the same name). and the separator for array items.
- NetGuardLogLevel
- Severity levels for NetGuard logging.
- NetworkStatus
- Coarse connectivity state reported by NetworkService.
- OfflineBehavior
- What NetGuard does with a request made while the device is offline.
- ResponseSource
- Where a response ultimately came from.
- ResponseType
- Indicates which transformation should be applied to the response data.
Extensions
- NetGuardApiError on NetGuardError
- Convenience accessors for API error payloads.
- NetGuardErrorExtension on DioException
- Convenience predicates on DioException.
-
NetGuardResponseExtension
on Response<
T> - Convenience predicates on Response.
Typedefs
- NetGuardError = DioException
- NetGuard errors are Dio exceptions.
- NetGuardErrorType = DioExceptionType
- NetGuard error categories are Dio exception types.
- NetGuardLogSink = void Function(NetGuardLogRecord record)
-
Destination for log records. Replace to forward NetGuard logs into your
own logging package instead of
print. -
NetGuardResponse<
T> = Response< T> - NetGuard responses are Dio Response objects.
- ProgressCallback = void Function(int count, int total)
- The type of a progress listening callback when sending or receiving data.
-
RequestEncoder
= FutureOr<
List< Function(String request, RequestOptions options)int> > - The type of a request encoding callback.
-
ResponseDecoder
= FutureOr<
String?> Function(List<int> responseBytes, RequestOptions options, ResponseBody responseBody) - The type of a response decoding callback.
- ValidateStatus = bool Function(int? status)
- The type of a response status code validate callback.
Exceptions / Errors
- CacheMissException
- Thrown when CachePolicy.cacheOnly finds nothing cached.
- CertificatePinningException
- Thrown when a server presents a certificate that is not pinned.
- DioException
- DioException describes the exception info when a request failed.
- NetworkOfflineException
- Thrown when a request cannot proceed because the device is offline.