ApiConfig class

Immutable configuration object for ApiManager.

Bundles all the parameters required to bootstrap the API layer: base URL, API version prefix, request timeout, default headers and the default behaviour for tenant header injection.

Prefer this over the legacy ApiManager.configure(...) static method — it scales better when more options are added in the future and keeps the configuration explicit and testable.

Example:

const config = ApiConfig(
  baseUrl: 'https://api.skillera.it/api/',
  apiVersion: 'v1/',
  timeout: Duration(seconds: 30),
  needTenantByDefault: true,
);
ApiManager.fromConfig(config);
Annotations

Constructors

ApiConfig({required String baseUrl, required String apiVersion, Duration timeout = const Duration(seconds: 30), Map<String, String> defaultHeaders = const {}, bool needTenantByDefault = false})
Creates an immutable ApiConfig.
const

Properties

apiVersion String
API version prefix injected between baseUrl and the call URL (e.g. "v1/"). Use empty string to disable.
final
baseUrl String
Base URL for every API request (must end with /).
final
defaultHeaders Map<String, String>
Headers attached to every request unless overridden per call.
final
hashCode int
The hash code for this object.
no setterinherited
needTenantByDefault bool
When true, calls inject the x-tenant-id header by default. Individual calls can still override via their own needTenant flag.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
timeout Duration
Maximum duration for a single HTTP request before it is aborted.
final

Methods

copyWith({String? baseUrl, String? apiVersion, Duration? timeout, Map<String, String>? defaultHeaders, bool? needTenantByDefault}) ApiConfig
Returns a new ApiConfig with the provided fields replaced.
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