HttpAdapter constructor
HttpAdapter({
- Client? client,
- HttpClient? httpClient,
Creates an HttpAdapter.
创建 HttpAdapter。
Parameters / 参数:
client: Optional custom http.Client instance. If not provided, a default instance will be created. 可选的自定义 http.Client 实例。如果不提供,将创建默认实例。httpClient: Optional dart:io HttpClient for native configuration. When provided, connectTimeout/followRedirects/maxRedirects from AdapterBaseOptions will be applied directly. 可选的 dart:io HttpClient,用于原生参数配置。
Example / 示例:
// Using default client / 使用默认 client
final adapter = HttpAdapter();
// Using custom client with native config / 使用自定义 client
final httpClient = HttpClient()
..connectionTimeout = Duration(seconds: 10);
final adapter = HttpAdapter(httpClient: httpClient);
Implementation
HttpAdapter({http.Client? client, HttpClient? httpClient})
: _client = client ?? IOClient(httpClient ?? HttpClient()),
_nativeHttpClient = httpClient;