Cloudflare constructor

Cloudflare({
  1. String? apiUrl,
  2. required String accountId,
  3. String? token,
  4. TokenCallback? tokenCallback,
  5. String? apiKey,
  6. String? accountEmail,
  7. String? userServiceKey,
  8. @Deprecated('Use connectTimeout instead') Duration? timeout,
  9. Duration? connectTimeout,
  10. Duration? receiveTimeout,
  11. Duration? sendTimeout,
  12. HttpClient? httpClient,
})

Cloudflare brings you full access to different apis like ImageAPI and StreamAPI.

By default cloudflare api url v4 will be used unless you set a specific apiUrl.

The accountId is required as well as one of (token or tokenCallback) or (apiKey and accountEmail) or userServiceKey

Implementation

Cloudflare({
  String? apiUrl,
  required this.accountId,
  this.token,
  TokenCallback? tokenCallback,
  this.apiKey,
  this.accountEmail,
  this.userServiceKey,
  @Deprecated('Use connectTimeout instead') Duration? timeout,
  Duration? connectTimeout,
  this.receiveTimeout,
  this.sendTimeout,
  this.httpClient,
})  : assert(
          (((token?.isNotEmpty ?? false) && tokenCallback == null) ||
                  ((token?.isEmpty ?? true) && tokenCallback != null)) ||
              ((apiKey?.isNotEmpty ?? false) &&
                  (accountEmail?.isNotEmpty ?? false)) ||
              (userServiceKey?.isNotEmpty ?? false),
          '\n\nA token or tokenCallback must be specified, only one of both. '
          '\nOtherwise an apiKey and accountEmail must be specified. '
          '\nOtherwise a userServiceKey must be specified.'),
      apiUrl = apiUrl ?? defaultApiUrl,
      tokenCallback = tokenCallback ?? (() async => token),
      connectTimeout = connectTimeout ?? timeout;