init method

void init(
  1. HttpRequestSetting setting
)

初始化

Implementation

void init(HttpRequestSetting setting) {
  BaseOptions options = BaseOptions();
  options.baseUrl = setting.baseUrl;
  options.contentType = setting.contentType;
  options.sendTimeout = Duration(seconds: setting.sendTimeOut);
  options.connectTimeout = Duration(seconds: setting.connectTimeOut);
  options.receiveTimeout = Duration(seconds: setting.receiveTimeOut);
  _client = Dio(options);
  _client!.httpClientAdapter = getClientAdapter();
  if (setting.interceptors != null) {
    _client!.interceptors.addAll(setting.interceptors!);
  }
}