ApiConfig class
Global API Configuration Class This class manages all API settings including base URL, headers, timeouts, and more.
Constructors
- ApiConfig()
-
factory
Properties
- baseUrl → String
-
no setter
- checkInternetBeforeCall → bool
-
no setter
- connectTimeout → Duration
-
no setter
- enableLogs → bool
-
no setter
- enableRetry → bool
-
no setter
- exponentialBackoff → bool
-
no setter
- globalExceptionHandler → dynamic Function(dynamic exception)?
-
no setter
-
globalHeaders
→ Map<
String, dynamic> -
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
-
no setter
- receiveTimeout → Duration
-
no setter
- retryCount → int
-
no setter
- retryDelay → Duration
-
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- sendTimeout → Duration
-
no setter
- token → String?
-
no setter
Methods
-
addHeader(
String key, dynamic value) → void - Add or update a global header
-
clearHeaders(
) → void - Clear all global headers
-
initialize(
{required String baseUrl, Map< String, dynamic> ? headers, String? token, Duration? connectTimeout, Duration? receiveTimeout, Duration? sendTimeout, bool enableLogs = true, bool enableRetry = false, int retryCount = 3, Duration? retryDelay, bool exponentialBackoff = false, dynamic globalExceptionHandler(dynamic exception)?, dynamic onUnauthorized()?, bool checkInternetBeforeCall = true}) → void - Initialize configuration with required parameters
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
removeHeader(
String key) → void - Remove a global header
-
reset(
) → void - Reset configuration to defaults
-
setGlobalExceptionHandler(
dynamic handler(dynamic exception)?) → void - Set global exception handler
-
setLogging(
bool enable) → void - Enable or disable logging
- Set unauthorized callback
-
toString(
) → String -
A string representation of this object.
inherited
-
updateBaseUrl(
String newBaseUrl) → void - Update base URL dynamically
-
updateHeaders(
Map< String, dynamic> headers) → void - Update global headers
-
updateRetryConfig(
{bool? enableRetry, int? retryCount, Duration? retryDelay, bool? exponentialBackoff}) → void - Update retry configuration
-
updateTimeouts(
{Duration? connectTimeout, Duration? receiveTimeout, Duration? sendTimeout}) → void - Update timeout settings
-
updateToken(
String? newToken) → void - Update token dynamically (for authentication)
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited