RestAPIService<DataType extends Jsonable<Object>> constructor

RestAPIService<DataType extends Jsonable<Object>>({
  1. RestAPI? restAPI,
  2. void onInit()?,
  3. required String baseUrl,
  4. DataType? dataType,
  5. String? token,
  6. TokenCallback? tokenCallback,
  7. String? apiKey,
  8. Duration? connectTimeout,
  9. Duration? receiveTimeout,
  10. Duration? sendTimeout,
  11. HttpClientAdapter? httpClientAdapter,
})

Implementation

RestAPIService({
  RestAPI? restAPI,
  this.onInit,
  required this.baseUrl,
  this.dataType,
  this.token,
  TokenCallback? tokenCallback,
  this.apiKey,
  this.connectTimeout,
  this.receiveTimeout,
  this.sendTimeout,
  this.httpClientAdapter,
})  : assert(
          (((token?.isNotEmpty ?? false) && tokenCallback == null) ||
                  ((token?.isEmpty ?? true) && tokenCallback != null)) ||
              (apiKey?.isNotEmpty ?? false),
          '\n\nA token or tokenCallback must be specified, only one of both.'
          '\nOtherwise an apiKey must be specified.'),
      tokenCallback =
          tokenCallback ??= (token == null ? null : (() async => token)),
      restAPI = restAPI ?? RestAPI() {
  _init();
}