init static method
Must be called before using instance or request. Example:
await ApiService.init(baseUrl: "https://api.example.com");
Implementation
static Future<ApiService> init({
required String baseUrl,
bool needToShowLog = false,
bool needToLogRequests = false,
// unauthorized callback
NetworkMonitoringFunction? networkMonitoringFunction,
int? unauthorizedStatusCode = 401,
void Function()? onUnauthorizedCallBack,
bool needInitialGlobalInstance = true,
}) async {
final service = ApiService._internal();
await service.initConfig(
baseUrl: baseUrl,
needToShowLog: needToShowLog,
needToLogRequests: needToLogRequests,
networkMonitoringFunction: networkMonitoringFunction,
unauthorizedStatusCode: unauthorizedStatusCode,
onUnauthorizedCallBack: onUnauthorizedCallBack,
);
if (needInitialGlobalInstance) {
_instance = service;
}
return service;
}