AppClient constructor
AppClient({})
Implementation
factory AppClient({
bool isAuthorizationCustom = false,
String? token,
String? baseUrl,
bool enableErrorHandler = true,
BaseOptions? options,
List<Interceptor>? customInterceptors,
Duration? connectTimeout,
Duration? receiveTimeout,
bool forceNewInstance = false,
bool disableRemoveNull = false,
}) {
_enableErrorHandler = enableErrorHandler;
if (forceNewInstance ||
(baseUrl ?? appBaseUrl) != _instance?.options.baseUrl) {
_instance = AppClient._(
baseUrl: baseUrl ?? appBaseUrl,
options: options,
customInterceptors: customInterceptors,
connectTimeout: connectTimeout,
receiveTimeout: receiveTimeout,
disableRemoveNull: disableRemoveNull,
);
} else {
_instance ??= AppClient._(
baseUrl: baseUrl ?? appBaseUrl,
options: options,
customInterceptors: customInterceptors,
connectTimeout: connectTimeout,
receiveTimeout: receiveTimeout,
disableRemoveNull: disableRemoveNull,
);
}
if (options != null) _instance!.options = options;
_instance!.options.baseUrl = baseUrl ?? appBaseUrl;
if ((token == null || token.isEmpty)) {
_instance!.options.headers.remove(r'Authorization');
} else {
_instance!.options.headers.addAll({
r'Authorization': isAuthorizationCustom ? token : ('Bearer $token')
});
}
// _instance!.options.headers.addAll(appHeaders);
return _instance!;
}