DioApiService constructor

DioApiService(
  1. BuildContext? context, {
  2. BaseOptions baseOptions(
    1. BaseOptions baseOptions
    )?,
  3. Dio initDio(
    1. Dio api
    )?,
})

Implementation

DioApiService(BuildContext? context,
    {BaseOptions Function(BaseOptions baseOptions)? baseOptions,
    Dio Function(Dio api)? initDio}) {
  _initDio = initDio;
  _context = context;
  if (baseOptions != null) {
    BaseOptions baseOptionsFinal = BaseOptions();
    this.baseOptions = baseOptions(baseOptionsFinal);
    if (this.baseOptions?.baseUrl == null ||
        this.baseOptions?.baseUrl == '') {
      this.baseOptions?.baseUrl = baseUrl;
    }
  } else {
    this.baseOptions = BaseOptions(
      baseUrl: baseUrl,
      headers: {
        "Content-type": "application/json",
        "Accept": "application/json",
      },
      connectTimeout: const Duration(seconds: 5),
    );
  }
  init();
}