create static method
Dio
create({
- required String baseUrl,
- Duration? timeout,
- required LikeRequestRegistry registry,
- LikeSessionScope currentSession()?,
- LikeAuthConfig? authConfig,
- List<
Interceptor> customInterceptors = const [], - Map<
String, String> extraHeaders = const {}, - bool? verifySSL,
- String? sslCertSha256,
Implementation
static Dio create({
required String baseUrl,
Duration? timeout,
required LikeRequestRegistry registry,
LikeSessionScope Function()? currentSession,
/// Optional authentication configuration scoped to this Dio stack.
LikeAuthConfig? authConfig,
/// Custom Dio interceptors injected **after** the built-in Like stack.
///
/// Sourced from [LikeConfig.interceptors] (global) or
/// [LikeClientConfig.interceptors] (scoped client).
List<Interceptor> customInterceptors = const [],
/// Extra HTTP headers merged on top of the package-level defaults.
///
/// Sourced from [LikeClientConfig.defaultHeaders] for scoped clients.
Map<String, String> extraHeaders = const {},
/// Explicit SSL verification override. Defaults to [LikeConstants.verifySSL].
bool? verifySSL,
/// Explicit SSL certificate SHA-256 pin override. Defaults to [LikeConstants.sslCertSha256].
String? sslCertSha256,
}) {
final effectiveBaseUrl = LikeHelpers.normalizeBaseUrl(baseUrl);
final dio = Dio(
BaseOptions(
baseUrl: effectiveBaseUrl,
connectTimeout:
timeout ?? Duration(seconds: LikeConstants.connectTimeout),
receiveTimeout:
timeout ?? Duration(seconds: LikeConstants.receiveTimeout),
sendTimeout: kIsWeb
? null
: (timeout ?? Duration(seconds: LikeConstants.sendTimeout)),
headers: {'Accept': LikeConstants.defaultAcceptHeader, ...extraHeaders},
),
);
_setupInterceptors(
dio,
registry,
customInterceptors,
authConfig: authConfig,
currentSession: currentSession,
);
// Delegate to the platform-correct SSL implementation:
// • Mobile/Desktop → like_ssl_io.dart (IOHttpClientAdapter)
// • Web → like_ssl_stub.dart (no-op)
ssl.setupSSL(
dio,
verifySSL: verifySSL ?? LikeConstants.verifySSL,
sslCertSha256: sslCertSha256 ?? LikeConstants.sslCertSha256,
);
return dio;
}