SmartConfig class
Central configuration object for SmartNetworkClient.
Create ONE instance and pass it to SmartNetworkClient.initialize.
Example:
final config = SmartConfig(
baseUrl: 'https://api.example.com',
retryPolicy: RetryPolicy(maxAttempts: 3),
cachePolicy: CachePolicy(maxAge: Duration(minutes: 10)),
tokenRefresher: MyTokenRefresher(),
);
await SmartNetworkClient().initialize(config);
Constructors
-
SmartConfig({required String baseUrl, Duration connectTimeout = const Duration(seconds: 30), Duration receiveTimeout = const Duration(seconds: 30), Duration sendTimeout = const Duration(seconds: 30), Map<
String, dynamic> defaultHeaders = const {}, RetryPolicy retryPolicy = const RetryPolicy(), CachePolicy cachePolicy = const CachePolicy(), bool enableOfflineMode = true, bool enableDeduplication = true, TokenRefresher? tokenRefresher, BatchConfig? batchConfig, bool enableLogging = true, List<Interceptor> extraInterceptors = const [], String cacheBoxName = 'smart_network_cache', String offlineQueueBoxName = 'smart_network_offline_queue'}) -
const
Properties
- baseUrl → String
-
The base URL prepended to every request path.
final
- batchConfig → BatchConfig?
-
Enables request batching via a dedicated batch endpoint.
final
- cacheBoxName → String
-
Name of the Hive box used for cache storage.
final
- cachePolicy → CachePolicy
-
Controls caching strategy and TTL.
final
- connectTimeout → Duration
-
Timeout for establishing a connection (default: 30 seconds).
final
-
defaultHeaders
→ Map<
String, dynamic> -
Default headers merged into every request.
final
- enableDeduplication → bool
-
Prevents duplicate in-flight GET requests (default: true).
final
- enableLogging → bool
-
Enables structured console logging (default: true).
final
- enableOfflineMode → bool
-
Enables offline request queuing (default: true).
final
-
extraInterceptors
→ List<
Interceptor> -
Additional Dio interceptors appended after all built-in ones.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- offlineQueueBoxName → String
-
Name of the Hive box used for offline queue storage.
final
- receiveTimeout → Duration
-
Timeout for receiving a response (default: 30 seconds).
final
- retryPolicy → RetryPolicy
-
Controls automatic retry behaviour on failure.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- sendTimeout → Duration
-
Timeout for sending a request body (default: 30 seconds).
final
- tokenRefresher → TokenRefresher?
-
Provide a TokenRefresher to enable automatic JWT refresh.
final
Methods
-
copyWith(
{String? baseUrl, Duration? connectTimeout, Duration? receiveTimeout, Duration? sendTimeout, Map< String, dynamic> ? defaultHeaders, RetryPolicy? retryPolicy, CachePolicy? cachePolicy, bool? enableOfflineMode, bool? enableDeduplication, TokenRefresher? tokenRefresher, BatchConfig? batchConfig, bool? enableLogging, List<Interceptor> ? extraInterceptors, String? cacheBoxName, String? offlineQueueBoxName}) → SmartConfig - Creates a copy of this config with the given fields replaced.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited