timeout function
Implementation
PollStrategy timeout(Duration duration) {
final end = DateTime.now().add(duration);
return (
Principal canisterId,
RequestId requestId,
RequestStatusResponseStatus status,
) async {
if (DateTime.now().isAfter(end)) {
throw TimeoutException(
'Request timed out after $duration:\n'
' Request ID: ${requestIdToHex(requestId)}\n'
' Request status: $status\n',
duration,
);
}
};
}