Cloudflare constructor
Cloudflare({
- String? apiUrl,
- required String accountId,
- String? token,
- TokenCallback? tokenCallback,
- String? apiKey,
- String? accountEmail,
- String? userServiceKey,
- @Deprecated('Use connectTimeout instead') Duration? timeout,
- Duration? connectTimeout,
- Duration? receiveTimeout,
- Duration? sendTimeout,
- 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;