readBytes static method
Implementation
static Future<Uint8List?> readBytes(Uri url,
{Map<String, String>? headers,
CancellationToken? cancelToken,
int retries = 3,
Duration? timeLimit,
Duration timeRetry = const Duration(milliseconds: 100),
FutureOr<Uint8List> Function()? onTimeout}) async {
cancelToken?.throwIfCancellationRequested();
return await RetryHelper.tryRun<Uint8List>(
() {
return CancellationTokenSource.register(
cancelToken,
timeLimit == null
? _httpClient.readBytes(
url,
headers: headers,
)
: _httpClient
.readBytes(
url,
headers: headers,
)
.timeout(
timeLimit,
onTimeout: onTimeout,
),
);
},
cancelToken: cancelToken,
timeRetry: timeRetry,
retries: retries,
);
}