config method

void config({
  1. String? baseUrl,
  2. String? token,
  3. GetOption<String?>? getToken,
  4. GetAsyncOption<String?>? getAsyncToken,
  5. GetOption? unauthenticated,
  6. Map<String, dynamic>? defaultQueryParameters,
  7. String? tokenType,
  8. int? connectTimeout,
  9. bool? enableLog,
  10. List<ApiInterceptor>? interceptors,
})

Implementation

void config(
    {String? baseUrl,
    String? token,
    GetOption<String?>? getToken,
    GetAsyncOption<String?>? getAsyncToken,
    GetOption? unauthenticated,
    Map<String, dynamic>? defaultQueryParameters,
    String? tokenType,
    int? connectTimeout,
    bool? enableLog,
    List<ApiInterceptor>? interceptors}) async {
  this.baseUrl = baseUrl ?? this.baseUrl;
  this.token = token ?? this.token;
  this.getToken = getToken ?? this.getToken;
  this.getAsyncToken = getAsyncToken ?? this.getAsyncToken;
  this.unauthenticated = unauthenticated ?? this.unauthenticated;

  if (this.defaultQueryParameters.isNotEmpty) {
    this.defaultQueryParameters.addAll(defaultQueryParameters ?? {});
  } else {
    this.defaultQueryParameters =
        defaultQueryParameters ?? this.defaultQueryParameters;
  }

  if (this.interceptors.isNotEmpty) {
    this.interceptors.addAll(interceptors ?? []);
  } else {
    this.interceptors = interceptors ?? this.interceptors;
  }

  this.tokenType = tokenType ?? this.tokenType;
  this.connectTimeout = connectTimeout ?? this.connectTimeout;
  this.enableLog = enableLog ?? this.enableLog;
}