HttpClientConfiguration class

Holds the connection settings shared by all services of one HTTP client.

Create one configuration instance per external API and pass it via HttpServiceBase.configuration:

const githubConfig = HttpClientConfiguration(
  baseUri: 'https://api.github.com',
  logger: DevToolsHttpLogger(),
);

Constructors

HttpClientConfiguration({required String baseUri, HttpLogger logger = const NullHttpLogger(), HttpCache cache = const NullHttpCache(), Map<String, String> defaultHeaders = const {}, Duration connectTimeout = const Duration(seconds: 10), Duration receiveTimeout = const Duration(seconds: 30)})
Creates a configuration for an HTTP client.
const

Properties

baseUri String
The base URL for all requests made by services using this configuration.
final
cache HttpCache
Caches responses to avoid redundant network requests. Defaults to NullHttpCache (caching disabled).
final
connectTimeout Duration
Maximum time to wait for the connection to be established. Defaults to 10 seconds.
final
defaultHeaders Map<String, String>
Headers merged into every request made by services using this configuration. Per-request headers declared on the service take precedence over these defaults.
final
hashCode int
The hash code for this object.
no setterinherited
logger HttpLogger
Logs request and response details. Defaults to NullHttpLogger.
final
receiveTimeout Duration
Maximum time to wait for the full response to arrive after the connection is established. Defaults to 30 seconds.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

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