deliverFile static method
Future<ChartExportDeliveryResult>
deliverFile(
- ChartExportFile file,
- ChartExportDeliveryAdapter adapter, {
- Duration? timeout,
- ChartExportCancellationToken? cancellationToken,
Implementation
static Future<ChartExportDeliveryResult> deliverFile(
ChartExportFile file,
ChartExportDeliveryAdapter adapter, {
Duration? timeout,
ChartExportCancellationToken? cancellationToken,
}) async {
final stopwatch = Stopwatch()..start();
if (cancellationToken?.isCancelled == true) {
return _cancelledDeliveryResult(
file,
cancellationToken,
).withDuration(stopwatch.elapsed);
}
try {
final result = await _guardDelivery(
() => adapter.deliver(file),
file,
timeout: timeout,
cancellationToken: cancellationToken,
);
return result.withDuration(stopwatch.elapsed);
} catch (error, stackTrace) {
return ChartExportDeliveryResult.failure(
file: file,
error: error,
stackTrace: stackTrace,
duration: stopwatch.elapsed,
);
}
}