MultiEnvironmentConfig class abstract
Multi-environment configuration helper
Use this when you want to define all environments in one place.
Example:
class AppConfig extends MultiEnvironmentConfig {
const AppConfig(super.environment);
@override
String getBaseUrl(Environment env) {
return switch (env) {
Environment.development => 'https://dev-api.example.com',
Environment.staging => 'https://staging-api.example.com',
Environment.production => 'https://api.example.com',
};
}
@override
Map<String, dynamic> getHeaders(Environment env) {
return {
'X-App-Version': '1.0.0',
'X-Environment': env.name,
};
}
}
// Usage
const config = AppConfig(Environment.production);
- Implemented types
Constructors
- MultiEnvironmentConfig(Environment environment)
-
const
Properties
- baseUrl → String
-
Base URL for API requests
no setteroverride
- connectTimeout → Duration
-
Connection timeout duration
no setteroverride
- enableLogging → bool
-
Enable debug logging
no setteroverride
- environment → Environment
-
Current environment
final
- hashCode → int
-
The hash code for this object.
no setterinherited
-
headers
→ Map<
String, dynamic> -
Default headers for all requests
no setteroverride
- receiveTimeout → Duration
-
Response receive timeout duration
no setteroverride
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- sendTimeout → Duration
-
Request send timeout duration
no setteroverride
Methods
-
getBaseUrl(
Environment env) → String - Get base URL for the given environment
-
getConnectTimeout(
Environment env) → Duration - Get timeouts for the given environment
-
getHeaders(
Environment env) → Map< String, dynamic> - Get headers for the given environment
-
getReceiveTimeout(
Environment env) → Duration -
getSendTimeout(
Environment env) → Duration -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited